Fix shared dir not considered when counting files for the photos timeline

This commit is contained in:
Ming Ming 2024-11-20 00:52:52 +08:00
parent 97f1b25ae9
commit 5ec09d5c4c
4 changed files with 29 additions and 0 deletions

View file

@ -574,6 +574,7 @@ class FilesController {
.map((e) => File(path: file_util.unstripPath(account, e))
.strippedPathWithEmpty)
.toList(),
includeRelativeDirs: [accountPrefController.shareFolderValue],
excludeRelativeRoots: [remote_storage_util.remoteStorageDirRelativePath],
mimes: file_util.supportedFormatMimes,
);

View file

@ -412,6 +412,7 @@ abstract class NpDb {
Future<DbFilesSummary> getFilesSummary({
required DbAccount account,
List<String>? includeRelativeRoots,
List<String>? includeRelativeDirs,
List<String>? excludeRelativeRoots,
List<String>? mimes,
});

View file

@ -620,6 +620,7 @@ extension SqliteDbFileExtension on SqliteDb {
Future<CountFileGroupsByDateResult> countFileGroupsByDate({
required ByAccount account,
List<String>? includeRelativeRoots,
List<String>? includeRelativeDirs,
List<String>? excludeRelativeRoots,
List<String>? mimes,
bool? isArchived,
@ -627,10 +628,23 @@ extension SqliteDbFileExtension on SqliteDb {
_log.info(
"[countFileGroupsByDate] "
"includeRelativeRoots: $includeRelativeRoots, "
"includeRelativeDirs: $includeRelativeDirs, "
"excludeRelativeRoots: $excludeRelativeRoots, "
"mimes: $mimes",
);
List<int>? dirIds;
if (includeRelativeDirs?.isNotEmpty == true) {
final sqlAccount = await accountOf(account);
final result = await _accountFileRowIdsOf(ByAccount.sql(sqlAccount),
includeRelativeDirs!.map((e) => DbFileKey.byPath(e)).toList())
.notNull();
dirIds = result.values.map((e) => e.fileRowId).toList();
if (dirIds.length != includeRelativeDirs.length) {
_log.warning("Some dirs not found: $includeRelativeDirs");
}
}
final count = countAll();
final localDate = accountFiles.bestDateTime
.modify(const DateTimeModifier.localTime())
@ -647,6 +661,17 @@ extension SqliteDbFileExtension on SqliteDb {
for (final r in includeRelativeRoots) {
q.byOrRelativePathPattern("$r/%");
}
if (dirIds != null) {
for (final i in dirIds) {
q.byOrDirRowId(i);
}
}
}
} else {
if (dirIds != null) {
for (final i in dirIds) {
q.byOrDirRowId(i);
}
}
}
return q.build();

View file

@ -474,6 +474,7 @@ class NpDbSqlite implements NpDb {
Future<DbFilesSummary> getFilesSummary({
required DbAccount account,
List<String>? includeRelativeRoots,
List<String>? includeRelativeDirs,
List<String>? excludeRelativeRoots,
List<String>? mimes,
}) async {
@ -481,6 +482,7 @@ class NpDbSqlite implements NpDb {
return await db.countFileGroupsByDate(
account: ByAccount.db(account),
includeRelativeRoots: includeRelativeRoots,
includeRelativeDirs: includeRelativeDirs,
excludeRelativeRoots: excludeRelativeRoots,
mimes: mimes,
isArchived: false,