From 2919f39e402aa7219958454ca0da452af3e163e9 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sun, 10 Jun 2012 21:11:12 +0000 Subject: - Improve export encoding changes to occur after the export start, fixing errors when exports are interrupted, for example by file path errors, and then restarted. This addresses Issue #1364. --- Source/SPExportInitializer.m | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'Source/SPExportInitializer.m') diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m index d9ce4ecb..7ddf4aa8 100644 --- a/Source/SPExportInitializer.m +++ b/Source/SPExportInitializer.m @@ -68,6 +68,15 @@ didEndSelector:nil contextInfo:nil]; } + + // If using an export type that requires the connection to start in UTF8, cache the current connection + // encoding and then set it here. + if (exportType == SPSQLExport || exportType == SPDotExport) { + previousConnectionEncoding = [[NSString alloc] initWithString:[connection encoding]]; + previousConnectionEncodingViaLatin1 = [connection encodingUsesLatin1Transport]; + + [tableDocumentInstance setConnectionEncoding:@"utf8" reloadingViews:NO]; + } // Add the first exporter to the operation queue [operationQueue addOperation:[exporters objectAtIndex:0]]; @@ -281,12 +290,6 @@ [sqlExporter setSqlInsertAfterNValue:[exportSQLInsertNValueTextField integerValue]]; [sqlExporter setSqlInsertDivider:[exportSQLInsertDividerPopUpButton indexOfSelectedItem]]; - // Cache the current connection encoding then change it to UTF-8 to allow SQL dumps to work - previousConnectionEncoding = [[NSString alloc] initWithString:[connection encoding]]; - previousConnectionEncodingViaLatin1 = [connection encodingUsesLatin1Transport]; - - [tableDocumentInstance setConnectionEncoding:@"utf8" reloadingViews:NO]; - [sqlExporter setSqlExportTables:exportTables]; // Create custom filename if required @@ -380,13 +383,7 @@ [dotExporter setDotDatabaseHost:[tableDocumentInstance host]]; [dotExporter setDotDatabaseName:[tableDocumentInstance database]]; [dotExporter setDotDatabaseVersion:[tableDocumentInstance mySQLVersion]]; - - // Cache the current connection encoding then change it to UTF-8 to allow dumps to work - previousConnectionEncoding = [[NSString alloc] initWithString:[connection encoding]]; - previousConnectionEncodingViaLatin1 = [connection encodingUsesLatin1Transport]; - - [tableDocumentInstance setConnectionEncoding:@"utf8" reloadingViews:NO]; - + [dotExporter setDotExportTables:exportTables]; // Create custom filename if required -- cgit v1.2.3