diff --git a/app/lib/controller/files_controller.dart b/app/lib/controller/files_controller.dart index f5ad6630..56b46aaf 100644 --- a/app/lib/controller/files_controller.dart +++ b/app/lib/controller/files_controller.dart @@ -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, ); diff --git a/np_db/lib/src/api.dart b/np_db/lib/src/api.dart index d7fed616..3544f637 100644 --- a/np_db/lib/src/api.dart +++ b/np_db/lib/src/api.dart @@ -412,6 +412,7 @@ abstract class NpDb { Future getFilesSummary({ required DbAccount account, List? includeRelativeRoots, + List? includeRelativeDirs, List? excludeRelativeRoots, List? mimes, }); diff --git a/np_db_sqlite/lib/src/database/file_extension.dart b/np_db_sqlite/lib/src/database/file_extension.dart index 89ec5a68..ffa54db5 100644 --- a/np_db_sqlite/lib/src/database/file_extension.dart +++ b/np_db_sqlite/lib/src/database/file_extension.dart @@ -620,6 +620,7 @@ extension SqliteDbFileExtension on SqliteDb { Future countFileGroupsByDate({ required ByAccount account, List? includeRelativeRoots, + List? includeRelativeDirs, List? excludeRelativeRoots, List? mimes, bool? isArchived, @@ -627,10 +628,23 @@ extension SqliteDbFileExtension on SqliteDb { _log.info( "[countFileGroupsByDate] " "includeRelativeRoots: $includeRelativeRoots, " + "includeRelativeDirs: $includeRelativeDirs, " "excludeRelativeRoots: $excludeRelativeRoots, " "mimes: $mimes", ); + List? 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(); diff --git a/np_db_sqlite/lib/src/sqlite_api.dart b/np_db_sqlite/lib/src/sqlite_api.dart index c0cb90c2..7c7a1b00 100644 --- a/np_db_sqlite/lib/src/sqlite_api.dart +++ b/np_db_sqlite/lib/src/sqlite_api.dart @@ -474,6 +474,7 @@ class NpDbSqlite implements NpDb { Future getFilesSummary({ required DbAccount account, List? includeRelativeRoots, + List? includeRelativeDirs, List? excludeRelativeRoots, List? 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,