Deduplicate files
This commit is contained in:
parent
e5a07c86bf
commit
1677ed7334
1 changed files with 15 additions and 2 deletions
|
@ -16,9 +16,22 @@ class FileRepository {
|
|||
}
|
||||
|
||||
Future<List<File>> loadFiles() async {
|
||||
var files = await FilesDB.instance.getFiles();
|
||||
final files = await FilesDB.instance.getFiles();
|
||||
final deduplicatedFiles = List<File>();
|
||||
for (int index = 0; index < files.length; index++) {
|
||||
if (index != 0) {
|
||||
bool isSameUploadedFile = files[index].uploadedFileID != null &&
|
||||
(files[index].uploadedFileID == files[index - 1].uploadedFileID);
|
||||
bool isSameLocalFile = files[index].localID != null &&
|
||||
(files[index].localID == files[index - 1].localID);
|
||||
if (isSameUploadedFile || isSameLocalFile) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
deduplicatedFiles.add(files[index]);
|
||||
}
|
||||
_files.clear();
|
||||
_files.addAll(files);
|
||||
_files.addAll(deduplicatedFiles);
|
||||
|
||||
return _files;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue