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

View file

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