Skip to content

Commit

Permalink
Merge pull request #491 from waterkip/gh-475-decrease_display_time
Browse files Browse the repository at this point in the history
Decrease the time for the cli app to do things by @waterkip
  • Loading branch information
GPaulovics authored Mar 29, 2019
2 parents f38eb66 + 37800a9 commit 81ed15c
Showing 1 changed file with 15 additions and 10 deletions.
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

0 comments on commit 81ed15c

Please sign in to comment.