Workaround server bug where REPORT api no longer respect the path

This commit is contained in:
Ming Ming 2024-08-10 21:26:25 +08:00
parent d1d77ab2d2
commit 63c601f59a
6 changed files with 7 additions and 5 deletions

View file

@ -18,7 +18,7 @@ class FindFile {
/// [onFileNotFound] is null, a [StateError] will be thrown
Future<List<File>> call(
Account account,
List<int> fileIds, {
Iterable<int> fileIds, {
void Function(int fileId)? onFileNotFound,
}) async {
_log.info("[call] fileIds: ${fileIds.toReadableString()}");

View file

@ -24,9 +24,10 @@ class ListTaggedFile {
taggedFiles.addAll(await _c.taggedFileRepo
.list(account, File(path: file_util.unstripPath(account, r)), tags));
}
// server bug workaround, filter out repeated files
final files = await FindFile(_c)(
account,
taggedFiles.map((f) => f.fileId).toList(),
taggedFiles.map((f) => f.fileId).toSet(),
onFileNotFound: (id) {
// ignore missing file
_log.warning("[call] Missing file: $id");

View file

@ -293,6 +293,7 @@ class ApiFiles {
}
}
// SERVER_BUG: 26 to unknown. path is ignored by server
Future<Response> report({
required String path,
bool? favorite,

View file

@ -293,7 +293,7 @@ abstract class NpDb {
/// Returned files are NOT guaranteed to be sorted as [fileIds]
Future<List<DbFile>> getFilesByFileIds({
required DbAccount account,
required List<int> fileIds,
required Iterable<int> fileIds,
});
/// Return [DbFile]s by their date time value

View file

@ -111,7 +111,7 @@ extension SqliteDbFileExtension on SqliteDb {
/// Returned files are NOT guaranteed to be sorted as [fileIds]
Future<List<CompleteFile>> queryFilesByFileIds({
required ByAccount account,
required List<int> fileIds,
required Iterable<int> fileIds,
}) {
_log.info("[queryFilesByFileIds] fileIds: ${fileIds.toReadableString()}");
return fileIds.withPartition((sublist) {

View file

@ -236,7 +236,7 @@ class NpDbSqlite implements NpDb {
@override
Future<List<DbFile>> getFilesByFileIds({
required DbAccount account,
required List<int> fileIds,
required Iterable<int> fileIds,
}) async {
final sqlObjs = await _db.use((db) async {
return await db.queryFilesByFileIds(