diff --git a/SharedSources/MediaLibraryService.swift b/SharedSources/MediaLibraryService.swift index 62a76b994eecf2a631e91cb124bb48b7c3984386..66a4cc783389d3f9390c56df12bdc775c205083e 100644 --- a/SharedSources/MediaLibraryService.swift +++ b/SharedSources/MediaLibraryService.swift @@ -151,6 +151,21 @@ private extension MediaLibraryService { assertionFailure("MediaLibraryService: Medialibrary failed to start.") return } + + /* exclude Document directory from backup (QA1719) */ + if let documentPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first { + var excludeURL = URL(fileURLWithPath: documentPath) + var resourceValue = URLResourceValues() + + resourceValue.isExcludedFromBackup = true + + do { + try excludeURL.setResourceValues(resourceValue) + } catch let error { + assertionFailure("MediaLibraryService: start: \(error.localizedDescription)") + } + } + medialib.reload() medialib.discover(onEntryPoint: "file://" + path) } @@ -475,17 +490,6 @@ extension MediaLibraryService: VLCMediaFileDiscovererDelegate { guard !isLoading else { return } - /* exclude media files from backup (QA1719) */ - var excludeURL = URL(fileURLWithPath: filePath) - var resourceValue = URLResourceValues() - - resourceValue.isExcludedFromBackup = true - - do { - try excludeURL.setResourceValues(resourceValue) - } catch let error { - assertionFailure("MediaLibraryService: VLCMediaFileDiscovererDelegate: \(error.localizedDescription)") - } reload() } diff --git a/Sources/VLCMediaFileDiscoverer.m b/Sources/VLCMediaFileDiscoverer.m index 5c8fdfeda78911fde8b034e3f66d1acf924578f3..0ef77a81592b1e612fb7600ef18d0fd6a1f28893 100644 --- a/Sources/VLCMediaFileDiscoverer.m +++ b/Sources/VLCMediaFileDiscoverer.m @@ -263,7 +263,6 @@ const float MediaTimerInterval = 2.f; NSString *directoryPath = [self directoryPath]; NSMutableArray *foundFiles = [NSMutableArray arrayWithArray:[[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:nil]]; NSMutableArray *filePaths = [NSMutableArray array]; - NSURL *fileURL; while (foundFiles.count) { NSString *fileName = foundFiles.firstObject; NSString *filePath = [directoryPath stringByAppendingPathComponent:fileName]; @@ -276,17 +275,9 @@ const float MediaTimerInterval = 2.f; if (self.filterResultsForPlayability) { if ([fileName isSupportedMediaFormat] || [fileName isSupportedAudioMediaFormat]) { [filePaths addObject:filePath]; - - /* exclude media files from backup (QA1719) */ - fileURL = [NSURL fileURLWithPath:filePath]; - [fileURL setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil]; } } else { [filePaths addObject:filePath]; - - /* exclude media files from backup (QA1719) */ - fileURL = [NSURL fileURLWithPath:filePath]; - [fileURL setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil]; } } else if (exists && isDirectory) { // add folders