| | 33 | + (void)upgradeV1FileLinksFromContext:(NSManagedObjectContext *)oldMoc toContext:(NSManagedObjectContext *)newMoc directories:(NSDictionary *)dirLookup file:(NSDictionary *)fileLookup |
| | 34 | { |
| | 35 | NSArray *links = doFetchRequest(SapphireFileSymLinkName, oldMoc, nil); |
| | 36 | NSEnumerator *linkEnum = [links objectEnumerator]; |
| | 37 | NSManagedObject *oldLink; |
| | 38 | while((oldLink = [linkEnum nextObject]) != nil) |
| | 39 | { |
| | 40 | NSString *destinationPath = [oldLink valueForKeyPath:@"file.path"]; |
| | 41 | SapphireFileMetaData *destination = nil; |
| | 42 | if(destinationPath != nil) |
| | 43 | destination = [fileLookup objectForKey:destinationPath]; |
| | 44 | if(destination == nil) |
| | 45 | continue; |
| | 46 | |
| | 47 | NSString *containingPath = [oldLink valueForKeyPath:@"containingDirectory.path"]; |
| | 48 | SapphireDirectoryMetaData *containing = nil; |
| | 49 | if(containingPath != nil) |
| | 50 | containing = [dirLookup objectForKey:containingPath]; |
| | 51 | if(containing == nil) |
| | 52 | continue; |
| | 53 | |
| | 54 | SapphireFileSymLink *newLink = [NSEntityDescription insertNewObjectForEntityForName:SapphireFileSymLinkName inManagedObjectContext:newMoc]; |
| | 55 | newLink.path = [oldLink valueForKey:@"path"]; |
| | 56 | newLink.file = destination; |
| | 57 | newLink.containingDirectory = containing; |
| | 58 | } |
| | 59 | } |
| | 60 | |