[Playlist Loader] Extend deduplication to CUEs
CUEs will now deduplicate playlist entries based on their dependencies, and prevent loading redundant tracks if you add an entire directory, or use the option to add a directory when adding single files from it. Signed-off-by: Christopher Snowhill <kode54@gmail.com>main
parent
59ac5769ad
commit
03c498c0fc
|
@ -342,6 +342,7 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc
|
|||
NSMutableArray *fileURLs = [NSMutableArray array];
|
||||
NSMutableArray *validURLs = [NSMutableArray array];
|
||||
NSMutableArray *folderURLs = [NSMutableArray array];
|
||||
NSMutableArray *dependencyURLs = [NSMutableArray array];
|
||||
NSDictionary *xmlData = nil;
|
||||
|
||||
BOOL addOtherFilesInFolder = [[NSUserDefaults standardUserDefaults] boolForKey:@"addOtherFilesInFolders"];
|
||||
|
@ -423,6 +424,9 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc
|
|||
|
||||
// Make sure the container isn't added twice.
|
||||
[uniqueURLs addObject:url];
|
||||
|
||||
// Find the dependencies
|
||||
NSArray *depURLs = [AudioContainer dependencyUrlsForContainerURL:url];
|
||||
|
||||
BOOL localFound = NO;
|
||||
for(NSURL *u in urls) {
|
||||
|
@ -431,6 +435,16 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(depURLs) {
|
||||
[dependencyURLs addObjectsFromArray:depURLs];
|
||||
|
||||
for(NSURL *u in depURLs) {
|
||||
if([u isFileURL]) {
|
||||
localFound = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(localFound) {
|
||||
[[SandboxBroker sharedSandboxBroker] requestFolderForFile:url];
|
||||
}
|
||||
|
@ -459,6 +473,16 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc
|
|||
|
||||
// Deduplication of contained URLs
|
||||
[fileURLs removeObjectsInArray:containedURLs];
|
||||
[fileURLs removeObjectsInArray:dependencyURLs];
|
||||
for(NSURL *u in dependencyURLs) {
|
||||
for(NSUInteger c = 0; c < [containedURLs count];) {
|
||||
if([[u path] isEqualToString:[containedURLs[c] path]]) {
|
||||
[containedURLs removeObjectAtIndex:c];
|
||||
} else {
|
||||
++c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DLog(@"File urls: %@", fileURLs);
|
||||
|
||||
|
|
Loading…
Reference in New Issue