|
@@ -203,12 +203,15 @@ class SyncService {
|
|
_collectionsService.getCollectionSyncTime(collectionID),
|
|
_collectionsService.getCollectionSyncTime(collectionID),
|
|
_diffLimit,
|
|
_diffLimit,
|
|
);
|
|
);
|
|
- if (diff.isNotEmpty) {
|
|
|
|
- await _storeDiff(diff, collectionID);
|
|
|
|
- _logger.info("Updated files in collection " + collectionID.toString());
|
|
|
|
|
|
+ if (diff.updatedFiles.isNotEmpty) {
|
|
|
|
+ await _storeDiff(diff.updatedFiles, collectionID);
|
|
|
|
+ _logger.info("Updated " +
|
|
|
|
+ diff.updatedFiles.length.toString() +
|
|
|
|
+ " files in collection " +
|
|
|
|
+ collectionID.toString());
|
|
FileRepository.instance.reloadFiles();
|
|
FileRepository.instance.reloadFiles();
|
|
Bus.instance.fire(CollectionUpdatedEvent(collectionID: collectionID));
|
|
Bus.instance.fire(CollectionUpdatedEvent(collectionID: collectionID));
|
|
- if (diff.length == _diffLimit) {
|
|
|
|
|
|
+ if (diff.fetchCount == _diffLimit) {
|
|
return await _fetchEncryptedFilesDiff(collectionID);
|
|
return await _fetchEncryptedFilesDiff(collectionID);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -222,9 +225,11 @@ class SyncService {
|
|
filesToBeUploaded
|
|
filesToBeUploaded
|
|
.removeWhere((element) => element.fileType == FileType.video);
|
|
.removeWhere((element) => element.fileType == FileType.video);
|
|
}
|
|
}
|
|
- final futures = List<Future>();
|
|
|
|
|
|
+ _logger.info(
|
|
|
|
+ filesToBeUploaded.length.toString() + " new files to be uploaded.");
|
|
|
|
|
|
final updatedFileIDs = await _db.getUploadedFileIDsToBeUpdated();
|
|
final updatedFileIDs = await _db.getUploadedFileIDsToBeUpdated();
|
|
|
|
+ _logger.info(updatedFileIDs.length.toString() + " files updated.");
|
|
|
|
|
|
int uploadCounter = 0;
|
|
int uploadCounter = 0;
|
|
final totalUploads = filesToBeUploaded.length + updatedFileIDs.length;
|
|
final totalUploads = filesToBeUploaded.length + updatedFileIDs.length;
|
|
@@ -233,6 +238,7 @@ class SyncService {
|
|
Bus.instance.fire(SyncStatusUpdate(SyncStatus.preparing_for_upload));
|
|
Bus.instance.fire(SyncStatusUpdate(SyncStatus.preparing_for_upload));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ final futures = List<Future>();
|
|
for (final uploadedFileID in updatedFileIDs) {
|
|
for (final uploadedFileID in updatedFileIDs) {
|
|
if (_syncStopRequested) {
|
|
if (_syncStopRequested) {
|
|
_syncStopRequested = false;
|
|
_syncStopRequested = false;
|
|
@@ -286,10 +292,12 @@ class SyncService {
|
|
|
|
|
|
Future _storeDiff(List<File> diff, int collectionID) async {
|
|
Future _storeDiff(List<File> diff, int collectionID) async {
|
|
for (File file in diff) {
|
|
for (File file in diff) {
|
|
- final existingFiles = await _db.getMatchingFiles(file.title,
|
|
|
|
- file.deviceFolder, file.creationTime, file.modificationTime);
|
|
|
|
|
|
+ final existingFiles = await _db.getMatchingFiles(
|
|
|
|
+ file.title, file.deviceFolder, file.creationTime);
|
|
if (existingFiles == null) {
|
|
if (existingFiles == null) {
|
|
// File uploaded from a different device
|
|
// File uploaded from a different device
|
|
|
|
+ _logger.info("Could not find a matching file for " +
|
|
|
|
+ file.uploadedFileID.toString());
|
|
file.localID = null;
|
|
file.localID = null;
|
|
await _db.insert(file);
|
|
await _db.insert(file);
|
|
} else {
|
|
} else {
|
|
@@ -300,6 +308,12 @@ class SyncService {
|
|
existingFiles.length == 1 && existingFiles[0].collectionID == null;
|
|
existingFiles.length == 1 && existingFiles[0].collectionID == null;
|
|
if (wasUploadedOnAPreviousInstallation) {
|
|
if (wasUploadedOnAPreviousInstallation) {
|
|
file.generatedID = existingFiles[0].generatedID;
|
|
file.generatedID = existingFiles[0].generatedID;
|
|
|
|
+ if (file.modificationTime != existingFiles[0].modificationTime) {
|
|
|
|
+ // File was updated since the app was uninstalled
|
|
|
|
+ _logger.info("Updated since last installation: " +
|
|
|
|
+ file.uploadedFileID.toString());
|
|
|
|
+ file.updationTime = null;
|
|
|
|
+ }
|
|
await _db.update(file);
|
|
await _db.update(file);
|
|
} else {
|
|
} else {
|
|
bool foundMatchingCollection = false;
|
|
bool foundMatchingCollection = false;
|