Skip to content

Commit

Permalink
[TIMOB-6756] Ensure proper paths for database migration
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalduggal committed Dec 19, 2011
1 parent a4ca4b8 commit d3b4341
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions iphone/Classes/TiDatabaseProxy.m
Expand Up @@ -72,13 +72,13 @@ -(NSString*)dbDir

// Migrate any old data if available
NSString* oldRoot = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* oldPath = [oldRoot stringByAppendingString:@"database"];
NSString* oldPath = [oldRoot stringByAppendingPathComponent:@"database"];
BOOL oldCopyExists = [fm fileExistsAtPath:oldPath isDirectory:&isDirectory];
if (oldCopyExists && isDirectory) {
NSDirectoryEnumerator* contents = [fm enumeratorAtPath:oldPath];

//This gives relative paths. So create full path before moving
for (NSString* oldFile in contents) {
[fm moveItemAtPath:oldFile toPath:[dbPath stringByAppendingPathComponent:[oldFile lastPathComponent]] error:nil];
[fm moveItemAtPath:[oldPath stringByAppendingPathComponent:oldFile] toPath:[dbPath stringByAppendingPathComponent:oldFile] error:nil];
}

// Remove the old copy after migrating everything
Expand Down

0 comments on commit d3b4341

Please sign in to comment.