aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPExportInitializer.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-06-07 21:59:39 +0000
committerstuconnolly <stuart02@gmail.com>2010-06-07 21:59:39 +0000
commitceffd765f621e4ad1f9d4d6775c8e55d2f136bfb (patch)
tree32025c0272b128be5189075e864ec1444318094a /Source/SPExportInitializer.m
parent4c7cbdf882ad1e1bb1a5a11dc59dc53b90bee686 (diff)
downloadsequelpro-ceffd765f621e4ad1f9d4d6775c8e55d2f136bfb.tar.gz
sequelpro-ceffd765f621e4ad1f9d4d6775c8e55d2f136bfb.tar.bz2
sequelpro-ceffd765f621e4ad1f9d4d6775c8e55d2f136bfb.zip
When cancelling an export remove all files already written to disk.
Diffstat (limited to 'Source/SPExportInitializer.m')
-rw-r--r--Source/SPExportInitializer.m16
1 files changed, 10 insertions, 6 deletions
diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m
index c5779dc6..4b7dc38c 100644
--- a/Source/SPExportInitializer.m
+++ b/Source/SPExportInitializer.m
@@ -574,13 +574,13 @@
/**
* Returns a file handle for writing at the supplied path.
*/
-- (SPFileHandle *)getFileHandleForFilePath:(NSString *)filePath
+- (SPFileHandle *)getFileHandleForFilePath:(NSString *)path
{
SPFileHandle *fileHandle = nil;
NSFileManager *fileManager = [NSFileManager defaultManager];
- if ([fileManager fileExistsAtPath:filePath]) {
- if ((![fileManager isWritableFileAtPath:filePath]) || (!(fileHandle = [SPFileHandle fileHandleForWritingAtPath:filePath]))) {
+ if ([fileManager fileExistsAtPath:path]) {
+ if ((![fileManager isWritableFileAtPath:path]) || (!(fileHandle = [SPFileHandle fileHandleForWritingAtPath:path]))) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil,
NSLocalizedString(@"Couldn't replace the file. Be sure that you have the necessary privileges.", @"message of panel when file cannot be replaced"));
return nil;
@@ -588,17 +588,17 @@
}
// Otherwise attempt to create a file
else {
- if (![fileManager createFileAtPath:filePath contents:[NSData data] attributes:nil]) {
+ if (![fileManager createFileAtPath:path contents:[NSData data] attributes:nil]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil,
NSLocalizedString(@"Couldn't write to file. Be sure that you have the necessary privileges.", @"message of panel when file cannot be written"));
return nil;
}
// Retrieve a filehandle for the file, attempting to delete it on failure.
- fileHandle = [SPFileHandle fileHandleForWritingAtPath:filePath];
+ fileHandle = [SPFileHandle fileHandleForWritingAtPath:path];
if (!fileHandle) {
- [[NSFileManager defaultManager] removeFileAtPath:filePath handler:nil];
+ [[NSFileManager defaultManager] removeFileAtPath:path handler:nil];
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil,
NSLocalizedString(@"Couldn't write to file. Be sure that you have the necessary privileges.", @"message of panel when file cannot be written"));
@@ -606,6 +606,10 @@
}
}
+ // Keep a record of the file handle's path in case the user cancels the export then we need to remove
+ // it from disk.
+ [exportFiles addObject:path];
+
return fileHandle;
}