Fix bug in handling file update
This commit is contained in:
parent
8894c61d98
commit
ef5d47c584
3 changed files with 14 additions and 3 deletions
|
@ -770,12 +770,17 @@ class FilesDB {
|
||||||
return uploadedFileIDs;
|
return uploadedFileIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<File?> getUploadedFileInAnyCollection(int uploadedFileID) async {
|
Future<File?> getUploadedLocalFileInAnyCollection(
|
||||||
|
int uploadedFileID,
|
||||||
|
int userID,
|
||||||
|
) async {
|
||||||
final db = await instance.database;
|
final db = await instance.database;
|
||||||
final results = await db.query(
|
final results = await db.query(
|
||||||
filesTable,
|
filesTable,
|
||||||
where: '$columnUploadedFileID = ?',
|
where: '$columnLocalID IS NOT NULL AND $columnOwnerID = ? AND '
|
||||||
|
'$columnUploadedFileID = ?',
|
||||||
whereArgs: [
|
whereArgs: [
|
||||||
|
userID,
|
||||||
uploadedFileID,
|
uploadedFileID,
|
||||||
],
|
],
|
||||||
limit: 1,
|
limit: 1,
|
||||||
|
|
|
@ -519,7 +519,10 @@ class RemoteSyncService {
|
||||||
.info("Skipping some updated files as we are throttling uploads");
|
.info("Skipping some updated files as we are throttling uploads");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
final file = await _db.getUploadedFileInAnyCollection(uploadedFileID);
|
final file = await _db.getUploadedLocalFileInAnyCollection(
|
||||||
|
uploadedFileID,
|
||||||
|
ownerID,
|
||||||
|
);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
_uploadFile(file, file.collectionID!, futures);
|
_uploadFile(file, file.collectionID!, futures);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,9 @@ class FileUploader {
|
||||||
// upload future will return null as File when the file entry is deleted
|
// upload future will return null as File when the file entry is deleted
|
||||||
// locally because it's already present in the destination collection.
|
// locally because it's already present in the destination collection.
|
||||||
Future<File> upload(File file, int collectionID) {
|
Future<File> upload(File file, int collectionID) {
|
||||||
|
if (file.localID == null || file.localID!.isEmpty) {
|
||||||
|
return Future.error(Exception("file's localID can not be null or empty"));
|
||||||
|
}
|
||||||
// If the file hasn't been queued yet, queue it
|
// If the file hasn't been queued yet, queue it
|
||||||
_totalCountInUploadSession++;
|
_totalCountInUploadSession++;
|
||||||
if (!_queue.containsKey(file.localID)) {
|
if (!_queue.containsKey(file.localID)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue