mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-30 13:19:44 +02:00
fix(library): preserve cached covers across directory aliases
This commit is contained in:
1 parent
ae78519490
commit
347208b3d9
3 files changed
+75
-17
No files matched your search
@@ -102,6 +102,42 @@ void main() {
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
||||
tearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
|
||||
test(
|
||||
'cover cleanup preserves references through directory aliases',
|
||||
() async {
|
||||
final root = await Directory.systemTemp.createTemp(
|
||||
'library-cover-cleanup-',
|
||||
);
|
||||
addTearDown(() => root.delete(recursive: true));
|
||||
final directory = await Directory('${root.path}/covers').create();
|
||||
final alias = await Link('${root.path}/alias').create(directory.path);
|
||||
final canonical = await File(
|
||||
'${directory.path}/canonical.jpg',
|
||||
).writeAsBytes([1]);
|
||||
final legacy = await File(
|
||||
'${directory.path}/legacy.jpg',
|
||||
).writeAsBytes([2]);
|
||||
final orphan = await File(
|
||||
'${directory.path}/orphan.jpg',
|
||||
).writeAsBytes([3]);
|
||||
final outside = await File('${root.path}/outside.jpg').writeAsBytes([4]);
|
||||
await Link('${directory.path}/outside.jpg').create(outside.path);
|
||||
|
||||
final deleted =
|
||||
await pruneUnreferencedLibraryCovers(Directory(alias.path), {
|
||||
await canonical.resolveSymbolicLinks(),
|
||||
'${alias.path}/legacy.jpg',
|
||||
'${alias.path}/already-missing.jpg',
|
||||
});
|
||||
|
||||
expect(await canonical.exists(), isTrue);
|
||||
expect(await legacy.exists(), isTrue);
|
||||
expect(await orphan.exists(), isFalse);
|
||||
expect(await outside.readAsBytes(), [4]);
|
||||
expect(deleted, 1);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'cleanup pages without skipping after deletions and preserves unknown',
|
||||
() async {
|
||||
|
||||
Reference in new issue
Block a user