Permalink
Browse files

Made the directory name for storing moved aside files unique for each…

… call. There was the potential of a name clash if the method was called twice, and the directory could be removed prematurely.
  • Loading branch information...
1 parent aa2b685 commit cd6dd849f6e5a8a6b29d89f2f80fa3668e77134e @drewmccormack committed Jan 30, 2013
@@ -178,12 +178,12 @@ - (void)initiateDownloadsForURLs:(NSArray *)urls
- (void)checkUninitiatedUploadsForURLs:(NSArray *)urls
{
- NSFileManager *fm = [[NSFileManager alloc] init];
+ NSFileManager *fm = [[[NSFileManager alloc] init] autorelease];
// Create temporary directory for moved aside files
- NSString *tempDirPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"MovedAsideCloudFiles"];
- [fm removeItemAtPath:tempDirPath error:NULL];
- [fm createDirectoryAtPath:tempDirPath withIntermediateDirectories:YES attributes:nil error:NULL];
+ NSString *tempFilename = [NSString stringWithFormat:@"MovedAsideCloudFiles_%@", [[NSProcessInfo processInfo] globallyUniqueString]];
+ NSString *tempDirPath = [NSTemporaryDirectory() stringByAppendingPathComponent:tempFilename];
+ if ( ![fm createDirectoryAtPath:tempDirPath withIntermediateDirectories:YES attributes:nil error:NULL] ) return;
// Check for files that should be uploaded, but have gotten 'stuck'.
const NSTimeInterval ReuploadTimeInterval = 30*60; // 30 minutes
@@ -233,7 +233,6 @@ - (void)checkUninitiatedUploadsForURLs:(NSArray *)urls
}
[fm removeItemAtPath:tempDirPath error:NULL];
- [fm release];
}
- (void)cloudFilesDidChange:(NSNotification *)notif

0 comments on commit cd6dd84

Please sign in to comment.