Show
Ignore:
Timestamp:
01/08/09 21:03:22 (3 years ago)
Author:
gbooker
Message:

Switched the the next version of the metadata.
Fixes #264

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/CoreData/SapphireFrappliance/MetaData/SapphireMObjects/SapphireFileSymLink.m

    r586 r734  
    22#import "SapphireFileMetaData.h" 
    33#import "SapphireDirectoryMetaData.h" 
     4#import "CoreDataSupportFunctions.h" 
    45 
    56@implementation SapphireFileSymLink 
     
    3031} 
    3132 
     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 
    3261- (NSNumber *)watched 
    3362{