Skip to content

Commit

Permalink
Fix hwittenborn#239 (Google Drive crash on sync)
Browse files Browse the repository at this point in the history
The issue occurs when the remote timestamp in the DB is more recent than the next (i.e. time has gone backwards).

It's not possible to know which is "really" more recent here, so the safest thing to do is to report an error and skip that file.
  • Loading branch information
OMGtechy committed Nov 29, 2024
1 parent 9224b11 commit 72d87e8
Showing 1 changed file with 22 additions and 0 deletions.
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

0 comments on commit 72d87e8

Please sign in to comment.