Fix not considering owner id when counting files missing metadata

This commit is contained in:
Ming Ming 2024-11-18 01:30:48 +08:00
parent ce0b6d6c05
commit 4eab807524
4 changed files with 8 additions and 0 deletions

View file

@ -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) {

View file

@ -351,6 +351,7 @@ abstract class NpDb {
Future<int> countFilesByMissingMetadata({
required DbAccount account,
required List<String> mimes,
required String ownerId,
});
/// Delete a file or dir from db

View file

@ -340,6 +340,7 @@ extension SqliteDbFileExtension on SqliteDb {
required ByAccount account,
bool? isMissingMetadata,
List<String>? 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();
}

View file

@ -383,12 +383,14 @@ class NpDbSqlite implements NpDb {
Future<int> countFilesByMissingMetadata({
required DbAccount account,
required List<String> mimes,
required String ownerId,
}) async {
return _db.use((db) async {
return await db.countFiles(
account: ByAccount.db(account),
isMissingMetadata: true,
mimes: mimes,
ownerId: ownerId,
);
});
}