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

Fix #239 (Google Drive crash on sync) #240

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions src/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2413,6 +2413,28 @@ pub fn launch(app: &Application, background: bool) {
util::await_future(active_model.update(db)).unwrap();
};

// Google Drive can enter a strange state where timestamps go backwards
// leading to scenarios where:
//
// db_model.last_local_timestamp
// == db_model.last_remote_timestamp
// == l_timestamp
//
// but...
// remote_timestamp < db_model.last_remote_timestamp
//
// The db is no longer making sense in this scenario,
// so the most reasonable cause of action is to delete its entry.
if remote_timestamp < db_model.last_remote_timestamp as i64
{
add_error(SyncError::General(
remote_path_string.clone(),
"New remote timestamp is older than previous".into(),
));
delete_db_entry();
continue;
}

// Both items are more recent.
if let Some(l_timestamp) = local_timestamp
&& l_timestamp > db_model.last_local_timestamp as u64
Expand Down