diff --git a/app/lib/controller/metadata_controller.dart b/app/lib/controller/metadata_controller.dart index 0f3ce7a8..2d280801 100644 --- a/app/lib/controller/metadata_controller.dart +++ b/app/lib/controller/metadata_controller.dart @@ -68,6 +68,7 @@ class MetadataController { final missingCount = await _c.npDb.countFilesByMissingMetadata( account: account.toDb(), mimes: file_util.supportedImageFormatMimes, + ownerId: account.userId.toCaseInsensitiveString(), ); _log.info("[_startMetadataTask] Missing count: $missingCount"); if (missingCount > 0) { diff --git a/np_db/lib/src/api.dart b/np_db/lib/src/api.dart index 565b1469..d7fed616 100644 --- a/np_db/lib/src/api.dart +++ b/np_db/lib/src/api.dart @@ -351,6 +351,7 @@ abstract class NpDb { Future countFilesByMissingMetadata({ required DbAccount account, required List mimes, + required String ownerId, }); /// Delete a file or dir from db diff --git a/np_db_sqlite/lib/src/database/file_extension.dart b/np_db_sqlite/lib/src/database/file_extension.dart index ecf4ef4c..89ec5a68 100644 --- a/np_db_sqlite/lib/src/database/file_extension.dart +++ b/np_db_sqlite/lib/src/database/file_extension.dart @@ -340,6 +340,7 @@ extension SqliteDbFileExtension on SqliteDb { required ByAccount account, bool? isMissingMetadata, List? mimes, + String? ownerId, }) async { _log.info( "[countFiles] isMissingMetadata: $isMissingMetadata, mimes: $mimes"); @@ -380,6 +381,9 @@ extension SqliteDbFileExtension on SqliteDb { if (mimes != null) { query.where(files.contentType.isIn(mimes)); } + if (ownerId != null) { + query.where(files.ownerId.equals(ownerId)); + } return await query.map((r) => r.read(count)!).getSingle(); } diff --git a/np_db_sqlite/lib/src/sqlite_api.dart b/np_db_sqlite/lib/src/sqlite_api.dart index eeca157a..c0cb90c2 100644 --- a/np_db_sqlite/lib/src/sqlite_api.dart +++ b/np_db_sqlite/lib/src/sqlite_api.dart @@ -383,12 +383,14 @@ class NpDbSqlite implements NpDb { Future countFilesByMissingMetadata({ required DbAccount account, required List mimes, + required String ownerId, }) async { return _db.use((db) async { return await db.countFiles( account: ByAccount.db(account), isMissingMetadata: true, mimes: mimes, + ownerId: ownerId, ); }); }