Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Only consider files that are directly owned by user for free up space, not shared files

laurenspriem5b6deab45a08
diff --git a/mobile/apps/photos/lib/db/files_db.dart b/mobile/apps/photos/lib/db/files_db.dart
index eed8fe4a88..8bda9d4ff3 100644
--- a/mobile/apps/photos/lib/db/files_db.dart
+++ b/mobile/apps/photos/lib/db/files_db.dart
@@ -655,12 +655,15 @@ class FilesDB with SqlDbBase {
}
Future<FreeableFileIDs> getFreeableFileIDs({
+ required int ownerID,
Set<String> excludeLocalIDs = const {},
}) async {
final db = await instance.sqliteAsyncDB;
final results = await db.getAll(
'SELECT $columnLocalID, $columnUploadedFileID, $columnFileSize FROM $filesTable'
- ' WHERE $columnLocalID IS NOT NULL AND ($columnUploadedFileID IS NOT NULL AND $columnUploadedFileID IS NOT -1)',
+ ' WHERE $columnLocalID IS NOT NULL AND ($columnOwnerID IS NULL OR $columnOwnerID = ?) '
+ 'AND ($columnUploadedFileID IS NOT NULL AND $columnUploadedFileID IS NOT -1)',
+ [ownerID],
);
final Set<String> localIDs = <String>{};
final Set<int> uploadedIDs = <int>{};
diff --git a/mobile/apps/photos/lib/services/files_service.dart b/mobile/apps/photos/lib/services/files_service.dart
index 79310b919d..93a6e92b5b 100644
--- a/mobile/apps/photos/lib/services/files_service.dart
+++ b/mobile/apps/photos/lib/services/files_service.dart
@@ -75,6 +75,7 @@ class FilesService {
final bool hasMigratedSize = await FilesService.instance.hasMigratedSizes();
if (pathID == null) {
ids = await FilesDB.instance.getFreeableFileIDs(
+ ownerID: Configuration.instance.getUserID()!,
excludeLocalIDs: excludeLocalIDs,
);
} else {