mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-23 01:06:21 +01:00
Filter out invalid files
This commit is contained in:
parent
679c0dbae2
commit
368a6a6755
1 changed files with 14 additions and 5 deletions
|
@ -60,7 +60,7 @@ class FileWebdavDataSource implements FileDataSource {
|
||||||
final xml = XmlDocument.parse(response.body);
|
final xml = XmlDocument.parse(response.body);
|
||||||
final files = WebdavFileParser()(xml);
|
final files = WebdavFileParser()(xml);
|
||||||
// _log.fine("[list] Parsed files: [$files]");
|
// _log.fine("[list] Parsed files: [$files]");
|
||||||
return files.map((e) {
|
return files.where((element) => _validateFile(element)).map((e) {
|
||||||
if (e.metadata == null || e.metadata.fileEtag == e.etag) {
|
if (e.metadata == null || e.metadata.fileEtag == e.etag) {
|
||||||
return e;
|
return e;
|
||||||
} else {
|
} else {
|
||||||
|
@ -328,10 +328,14 @@ class FileAppDbDataSource implements FileDataSource {
|
||||||
if (results?.isNotEmpty == true) {
|
if (results?.isNotEmpty == true) {
|
||||||
final entries = results
|
final entries = results
|
||||||
.map((e) => AppDbFileEntry.fromJson(e.cast<String, dynamic>()));
|
.map((e) => AppDbFileEntry.fromJson(e.cast<String, dynamic>()));
|
||||||
return entries.map((e) {
|
return entries
|
||||||
|
.map((e) {
|
||||||
_log.info("[_doList] ${e.path}[${e.index}]");
|
_log.info("[_doList] ${e.path}[${e.index}]");
|
||||||
return e.data;
|
return e.data;
|
||||||
}).reduce((value, element) => value + element);
|
})
|
||||||
|
.reduce((value, element) => value + element)
|
||||||
|
.where((element) => _validateFile(element))
|
||||||
|
.toList();
|
||||||
} else {
|
} else {
|
||||||
throw CacheNotFoundException("No entry: $path");
|
throw CacheNotFoundException("No entry: $path");
|
||||||
}
|
}
|
||||||
|
@ -720,4 +724,9 @@ Future<void> _cacheListResults(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _validateFile(File f) {
|
||||||
|
// See: https://gitlab.com/nkming2/nc-photos/-/issues/9
|
||||||
|
return f.lastModified != null;
|
||||||
|
}
|
||||||
|
|
||||||
final _log = Logger("entity.file.data_source");
|
final _log = Logger("entity.file.data_source");
|
||||||
|
|
Loading…
Reference in a new issue