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

View file

@ -24,9 +24,10 @@ class ListTaggedFile {
taggedFiles.addAll(await _c.taggedFileRepo taggedFiles.addAll(await _c.taggedFileRepo
.list(account, File(path: file_util.unstripPath(account, r)), tags)); .list(account, File(path: file_util.unstripPath(account, r)), tags));
} }
// server bug workaround, filter out repeated files
final files = await FindFile(_c)( final files = await FindFile(_c)(
account, account,
taggedFiles.map((f) => f.fileId).toList(), taggedFiles.map((f) => f.fileId).toSet(),
onFileNotFound: (id) { onFileNotFound: (id) {
// ignore missing file // ignore missing file
_log.warning("[call] Missing file: $id"); _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({ Future<Response> report({
required String path, required String path,
bool? favorite, bool? favorite,

View file

@ -293,7 +293,7 @@ abstract class NpDb {
/// Returned files are NOT guaranteed to be sorted as [fileIds] /// Returned files are NOT guaranteed to be sorted as [fileIds]
Future<List<DbFile>> getFilesByFileIds({ Future<List<DbFile>> getFilesByFileIds({
required DbAccount account, required DbAccount account,
required List<int> fileIds, required Iterable<int> fileIds,
}); });
/// Return [DbFile]s by their date time value /// 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] /// Returned files are NOT guaranteed to be sorted as [fileIds]
Future<List<CompleteFile>> queryFilesByFileIds({ Future<List<CompleteFile>> queryFilesByFileIds({
required ByAccount account, required ByAccount account,
required List<int> fileIds, required Iterable<int> fileIds,
}) { }) {
_log.info("[queryFilesByFileIds] fileIds: ${fileIds.toReadableString()}"); _log.info("[queryFilesByFileIds] fileIds: ${fileIds.toReadableString()}");
return fileIds.withPartition((sublist) { return fileIds.withPartition((sublist) {

View file

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