Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrease the time for the cli app to do things #491

Merged
merged 2 commits into from
Mar 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,15 +910,19 @@ static struct blob *blob_get_latest(struct session *session, const unsigned char
local = local_blob(key, &session->private_key);
if (!local)
return lastpass_get_blob(session, key);

remote_version = lastpass_get_blob_version(session, key);

if (remote_version == 0) {
blob_free(local);
return NULL;
}
if (local->version < remote_version || (local->local_version && local->version == remote_version)) {

if (remote_version > local->version) {
blob_free(local);
return lastpass_get_blob(session, key);
}

config_touch("blob");
return local;
}
Expand All @@ -938,19 +942,20 @@ static time_t auto_sync_time(void)

struct blob *blob_load(enum blobsync sync, struct session *session, const unsigned char key[KDF_HASH_LEN])
{
if (sync == BLOB_SYNC_AUTO) {
if (!config_exists("blob"))
return blob_get_latest(session, key);
else if (time(NULL) - config_mtime("blob") <= auto_sync_time())
return local_blob(key, &session->private_key);
return blob_get_latest(session, key);
} else if (sync == BLOB_SYNC_YES)
if (sync == BLOB_SYNC_YES)
return blob_get_latest(session, key);
else if (sync == BLOB_SYNC_NO)

if (sync == BLOB_SYNC_NO)
return local_blob(key, &session->private_key);

return NULL;
if (config_exists("blob") &&
time(NULL) - config_mtime("blob") < auto_sync_time()) {
return local_blob(key, &session->private_key);
}

return blob_get_latest(session, key);
}

void blob_save(const struct blob *blob, const unsigned char key[KDF_HASH_LEN])
{
_cleanup_free_ char *bluffer = NULL;
Expand Down