Fix: only attempt to update files ownedBy user

This commit is contained in:
Neeraj Gupta 2022-08-26 12:34:41 +05:30
parent 5ad1196172
commit 919186a9c9
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
2 changed files with 11 additions and 5 deletions

View file

@ -744,13 +744,16 @@ class FilesDB {
return convertToFiles(results);
}
Future<List<int>> getUploadedFileIDsToBeUpdated() async {
Future<List<int>> getUploadedFileIDsToBeUpdated(int ownerID) async {
final db = await instance.database;
final rows = await db.query(
filesTable,
columns: [columnUploadedFileID],
where:
'($columnLocalID IS NOT NULL AND ($columnUploadedFileID IS NOT NULL AND $columnUploadedFileID IS NOT -1) AND $columnUpdationTime IS NULL)',
where: '($columnLocalID IS NOT NULL AND $columnOwnerID = ? AND '
'($columnUploadedFileID '
'IS NOT '
'NULL AND $columnUploadedFileID IS NOT -1) AND $columnUpdationTime IS NULL)',
whereArgs: [ownerID],
orderBy: '$columnCreationTime DESC',
distinct: true,
);

View file

@ -299,8 +299,11 @@ class RemoteSyncService {
}
Future<bool> _uploadFiles(List<File> filesToBeUploaded) async {
final updatedFileIDs = await _db.getUploadedFileIDsToBeUpdated();
_logger.info(updatedFileIDs.length.toString() + " files updated.");
int ownerID = Configuration.instance.getUserID();
final updatedFileIDs = await _db.getUploadedFileIDsToBeUpdated(ownerID);
if (updatedFileIDs.isNotEmpty) {
_logger.info("Identified ${updatedFileIDs.length} files for reupload");
}
_completedUploads = 0;
int toBeUploaded = filesToBeUploaded.length + updatedFileIDs.length;