aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPExportInitializer.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-07-24 21:34:05 +0000
committerstuconnolly <stuart02@gmail.com>2010-07-24 21:34:05 +0000
commitbf1294bd1016672aa3062bb80b546bf2f8037fb3 (patch)
tree121768027638e59af7d5830855bd19b88de7e601 /Source/SPExportInitializer.m
parenteb29a57a6860961c0caa00787d779f4cb4117c90 (diff)
downloadsequelpro-bf1294bd1016672aa3062bb80b546bf2f8037fb3.tar.gz
sequelpro-bf1294bd1016672aa3062bb80b546bf2f8037fb3.tar.bz2
sequelpro-bf1294bd1016672aa3062bb80b546bf2f8037fb3.zip
In addition to Gzip compression support when exporting SQL dumps add the ability to use Bzip2 compression.
Other changes include: + Enable the use of export compression (Gzip and Bzip2) for all export formats. + Move the compression options in the export dialog to the 'Advanced' export settings view. + Simplify the setting of common exporter properties (e.g. the connection, use of compression). + Fix a potential memory leak in the dot exporter. + Update the data importer to recognise Bzip2 compressed files. + Fix several display issues on export dialog. + Restore the default .csv file extension of CSV exports. + Correctly update the default export filename when selecting a output compression type. The addition of Bzip2 compression support implements issue #688.
Diffstat (limited to 'Source/SPExportInitializer.m')
-rw-r--r--Source/SPExportInitializer.m69
1 files changed, 21 insertions, 48 deletions
diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m
index 2478b1b3..fab11da9 100644
--- a/Source/SPExportInitializer.m
+++ b/Source/SPExportInitializer.m
@@ -187,6 +187,8 @@
}
}
+ [exportFilename setString:[exportFilename stringByAppendingPathExtension:[self _currentDefaultExportFileExtension]]];
+
singleFileHandle = [self getFileHandleForFilePath:[[exportPathField stringValue] stringByAppendingPathComponent:exportFilename]];
}
@@ -267,17 +269,11 @@
[sqlExporter setSqlOutputIncludeUTF8BOM:[exportUseUTF8BOMButton state]];
[sqlExporter setSqlOutputEncodeBLOBasHex:[exportSQLBLOBFieldsAsHexCheck state]];
- [sqlExporter setSqlOutputCompressFile:[exportCompressOutputFile state]];
[sqlExporter setSqlOutputIncludeErrors:[exportSQLIncludeErrorsCheck state]];
[sqlExporter setSqlInsertAfterNValue:[exportSQLInsertNValueTextField integerValue]];
[sqlExporter setSqlInsertDivider:[exportSQLInsertDividerPopUpButton indexOfSelectedItem]];
- // Set generic properties
- [sqlExporter setConnection:connection];
- [sqlExporter setExportOutputEncoding:[connection encoding]];
- [sqlExporter setExportUsingLowMemoryBlockingStreaming:[exportProcessLowMemoryButton state]];
-
// Cache the current connection encoding then change it to UTF-8 to allow SQL dumps to work
sqlPreviousConnectionEncoding = [[NSString alloc] initWithString:[tableDocumentInstance connectionEncoding]];
sqlPreviousConnectionEncodingViaLatin1 = [tableDocumentInstance connectionEncodingViaLatin1:nil];
@@ -286,15 +282,10 @@
[sqlExporter setSqlExportTables:exportTables];
- // Set the exporter's max progress
- [sqlExporter setExportMaxProgress:((NSInteger)[exportProgressIndicator bounds].size.width)];
-
- // Set the progress bar's max value
- [exportProgressIndicator setMaxValue:[sqlExporter exportMaxProgress]];
-
// Create custom filename if required
[exportFilename setString:(createCustomFilename) ? [self expandCustomFilenameFormatFromString:[exportCustomFilenameTokenField stringValue] usingTableName:nil] : [NSString stringWithFormat:@"%@_%@", [tableDocumentInstance database], [[NSDate date] descriptionWithCalendarFormat:@"%Y-%m-%d" timeZone:nil locale:nil]]];
- [exportFilename setString:[exportFilename stringByAppendingPathExtension:([exportCompressOutputFile state]) ? [NSString stringWithFormat:@"%@.gz", SPFileExtensionSQL] : SPFileExtensionSQL]];
+
+ [exportFilename setString:[exportFilename stringByAppendingPathExtension:[self _currentDefaultExportFileExtension]]];
SPFileHandle *fileHandle = [self getFileHandleForFilePath:[[exportPathField stringValue] stringByAppendingPathComponent:exportFilename]];
@@ -333,7 +324,7 @@
}
}
- [exportFilename setString:[exportFilename stringByAppendingPathExtension:@"xml"]];
+ [exportFilename setString:[exportFilename stringByAppendingPathExtension:[self _currentDefaultExportFileExtension]]];
singleFileHandle = [self getFileHandleForFilePath:[[exportPathField stringValue] stringByAppendingPathComponent:exportFilename]];
}
@@ -382,15 +373,9 @@
SPDotExporter *dotExporter = [[SPDotExporter alloc] initWithDelegate:self];
[dotExporter setDotTableData:tableDataInstance];
-
[dotExporter setDotDatabaseHost:[tableDocumentInstance host]];
[dotExporter setDotDatabaseName:[tableDocumentInstance database]];
[dotExporter setDotDatabaseVersion:[tableDocumentInstance mySQLVersion]];
-
- // Set generic properties
- [dotExporter setConnection:connection];
- [dotExporter setExportOutputEncoding:[connection encoding]];
- [dotExporter setExportUsingLowMemoryBlockingStreaming:[exportProcessLowMemoryButton state]];
// Cache the current connection encoding then change it to UTF-8 to allow SQL dumps to work
sqlPreviousConnectionEncoding = [[NSString alloc] initWithString:[tableDocumentInstance connectionEncoding]];
@@ -400,12 +385,6 @@
[dotExporter setDotExportTables:exportTables];
- // Set the exporter's max progress
- [dotExporter setExportMaxProgress:(NSInteger)[exportProgressIndicator bounds].size.width];
-
- // Set the progress bar's max value
- [exportProgressIndicator setMaxValue:[dotExporter exportMaxProgress]];
-
// Create custom filename if required
if (createCustomFilename) {
[exportFilename setString:[self expandCustomFilenameFormatFromString:[exportCustomFilenameTokenField stringValue] usingTableName:nil]];
@@ -414,7 +393,7 @@
[exportFilename setString:[tableDocumentInstance database]];
}
- [exportFilename setString:[exportFilename stringByAppendingPathExtension:@"dot"]];
+ [exportFilename setString:[exportFilename stringByAppendingPathExtension:[self _currentDefaultExportFileExtension]]];
SPFileHandle *fileHandle = [self getFileHandleForFilePath:[[exportPathField stringValue] stringByAppendingPathComponent:exportFilename]];
@@ -424,6 +403,17 @@
[dotExporter release];
}
+
+ // For each of the created exporters, set their generic properties
+ for (SPExporter *exporter in exporters)
+ {
+ [exporter setConnection:connection];
+ [exporter setExportOutputEncoding:[connection encoding]];
+ [exporter setExportMaxProgress:(NSInteger)[exportProgressIndicator bounds].size.width];
+ [exporter setExportUsingLowMemoryBlockingStreaming:[exportProcessLowMemoryButton state]];
+ [exporter setExportOutputCompressionFormat:[exportOutputCompressionFormatPopupButton indexOfSelectedItem]];
+ [exporter setExportOutputCompressFile:([exportOutputCompressionFormatPopupButton indexOfSelectedItem] != SPNoCompression)];
+ }
// Add the first exporter to the operation queue
[operationQueue addOperation:[exporters objectAtIndex:0]];
@@ -451,7 +441,6 @@
}
[csvExporter setCsvTableData:tableDataInstance];
-
[csvExporter setCsvOutputFieldNames:[exportCSVIncludeFieldNamesCheck state]];
[csvExporter setCsvFieldSeparatorString:[exportCSVFieldsTerminatedField stringValue]];
[csvExporter setCsvEnclosingCharacterString:[exportCSVFieldsWrappedField stringValue]];
@@ -476,21 +465,14 @@
else {
[exportFilename setString:(dataArray) ? [tableDocumentInstance database] : table];
}
-
+
+ [exportFilename setString:[exportFilename stringByAppendingPathExtension:[self _currentDefaultExportFileExtension]]];
+
fileHandle = [self getFileHandleForFilePath:[[exportPathField stringValue] stringByAppendingPathComponent:exportFilename]];
[csvExporter setExportOutputFileHandle:fileHandle];
}
- // Set generic properties
- [csvExporter setConnection:connection];
- [csvExporter setExportOutputEncoding:[connection encoding]];
- [csvExporter setExportMaxProgress:((NSInteger)[exportProgressIndicator bounds].size.width)];
- [csvExporter setExportUsingLowMemoryBlockingStreaming:[exportProcessLowMemoryButton state]];
-
- // Set the progress bar's max value
- [exportProgressIndicator setMaxValue:[csvExporter exportMaxProgress]];
-
return [csvExporter autorelease];
}
@@ -520,7 +502,7 @@
// If required create separate files
if ((exportSource == SPTableExport) && exportToMultipleFiles && (exportTableCount > 0)) {
[exportFilename setString:[[exportPathField stringValue] stringByAppendingPathComponent:table]];
- [exportFilename setString:[exportFilename stringByAppendingPathExtension:@"xml"]];
+ [exportFilename setString:[exportFilename stringByAppendingPathExtension:[self _currentDefaultExportFileExtension]]];
fileHandle = [self getFileHandleForFilePath:exportFilename];
@@ -530,15 +512,6 @@
[xmlExporter setExportOutputFileHandle:fileHandle];
}
- // Set generic properties
- [xmlExporter setConnection:connection];
- [xmlExporter setExportOutputEncoding:[connection encoding]];
- [xmlExporter setExportMaxProgress:((NSInteger)[exportProgressIndicator bounds].size.width)];
- [xmlExporter setExportUsingLowMemoryBlockingStreaming:[exportProcessLowMemoryButton state]];
-
- // Set the progress bar's max value
- [exportProgressIndicator setMaxValue:[xmlExporter exportMaxProgress]];
-
return [xmlExporter autorelease];
}