Make sure that the right files are updated while applying a diff
This commit is contained in:
parent
b42c84cf42
commit
8334ec809e
1 changed files with 6 additions and 6 deletions
|
@ -231,17 +231,17 @@ class SyncService {
|
|||
file.generatedID = existingFiles[0].generatedID;
|
||||
await _db.update(file);
|
||||
} else {
|
||||
bool wasUpdatedInExistingCollection = false;
|
||||
bool foundMatchingCollection = false;
|
||||
for (final existingFile in existingFiles) {
|
||||
if (file.collectionID == existingFile.collectionID) {
|
||||
if (file.collectionID == existingFile.collectionID &&
|
||||
file.uploadedFileID == existingFile.uploadedFileID) {
|
||||
foundMatchingCollection = true;
|
||||
file.generatedID = existingFile.generatedID;
|
||||
wasUpdatedInExistingCollection = true;
|
||||
await _db.update(file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (wasUpdatedInExistingCollection) {
|
||||
await _db.update(file);
|
||||
} else {
|
||||
if (!foundMatchingCollection) {
|
||||
// Added to a new collection
|
||||
await _db.insert(file);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue