Replace when conflicts are encountered while applying remote diff

This commit is contained in:
Vishnu Mohandas 2020-11-14 15:41:12 +05:30
parent 5d0060031a
commit ee8d1e653c
2 changed files with 3 additions and 2 deletions

View file

@ -365,6 +365,7 @@ class FilesDB {
_getRowForFile(file),
where: '$columnGeneratedID = ?',
whereArgs: [file.generatedID],
conflictAlgorithm: ConflictAlgorithm.replace,
);
}

View file

@ -223,10 +223,10 @@ class SyncService {
await _db.insert(file);
} else {
// File exists on device
bool wasUploadedOnAPreviousInstallation =
existingFiles.length == 1 && existingFiles[0].collectionID == null;
file.localID = existingFiles[0]
.localID; // File should ideally have the same localID
bool wasUploadedOnAPreviousInstallation =
existingFiles.length == 1 && existingFiles[0].collectionID == null;
if (wasUploadedOnAPreviousInstallation) {
file.generatedID = existingFiles[0].generatedID;
await _db.update(file);