Commit 4512321f authored by Felix Paul Kühne's avatar Felix Paul Kühne

prevent media library from being partially reset when iOS app is upgraded...

prevent media library from being partially reset when iOS app is upgraded through the store (close #11330)
parent cd06da55
......@@ -170,7 +170,6 @@ NSString *kMLFileTypeAudio = @"audio";
@dynamic lastAudioTrack;
@dynamic playCount;
@dynamic artworkURL;
@dynamic url;
@dynamic type;
@dynamic title;
@dynamic shortSummary;
......@@ -207,7 +206,36 @@ NSString *kMLFileTypeAudio = @"audio";
[self didChangeValueForKey:@"lastPosition"];
}
@catch (NSException *exception) {
APLog(@"lastPosition raised exception");
APLog(@"setLastPosition raised exception");
}
}
- (NSString *)url
{
[self willAccessValueForKey:@"url"];
NSString *ret = [self primitiveValueForKey:@"url"];
[self didAccessValueForKey:@"url"];
/* we need to make sure that current app path is still part of the file
* URL since app upgrades via iTunes or the App Store will change the
* absolute URL of our files (trac #11330) */
if ([ret rangeOfString:[[MLMediaLibrary sharedMediaLibrary] documentFolderPath]].location != NSNotFound)
return ret;
ret = [[[MLMediaLibrary sharedMediaLibrary] documentFolderPath] stringByAppendingPathComponent:[ret lastPathComponent]];
APLog(@"returning modified URL! will return %@", ret);
return ret;
}
- (void)setUrl:(NSString *)url
{
@try {
[self willChangeValueForKey:@"url"];
[self setPrimitiveValue:url forKey:@"url"];
[self didChangeValueForKey:@"url"];
}
@catch (NSException *exception) {
APLog(@"setUrl raised exception");
}
}
......
......@@ -662,7 +662,14 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
for (NSString *path in filepaths) {
NSURL *url = [NSURL fileURLWithPath:path];
NSString *urlString = [url absoluteString];
#if TARGET_OS_IPHONE
/* check for the end of a path only, since parts of the path components may change
* while it is still the same file
* of course, this is only true for the flat file structure we use on iOS */
[fetchPredicates addObject:[NSPredicate predicateWithFormat:@"url ENDSWITH %@", [urlString lastPathComponent]]];
#else
[fetchPredicates addObject:[NSPredicate predicateWithFormat:@"url == %@", urlString]];
#endif
urlToObject[urlString] = path;
}
......@@ -829,7 +836,7 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
BOOL exists = [fileManager fileExistsAtPath:[fileURL path]];
if (!exists) {
APLog(@"Marking - %@", [fileURL absoluteString]);
file.isSafe = YES; // It doesn't exists, it's safe.
file.isSafe = YES; // It doesn't exist, it's safe.
if (file.isAlbumTrack) {
MLAlbum *album = file.albumTrack.album;
if (album.tracks.count <= 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment