Revision: 7778
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7778&view=rev
Author:   hofman
Date:     2012-11-04 00:12:20 +0000 (Sun, 04 Nov 2012)
Log Message:
-----------
Handle failure of archiving tasks

Modified Paths:
--------------
    trunk/SKAttachmentEmailer.h
    trunk/SKAttachmentEmailer.m
    trunk/SKMainDocument.m

Modified: trunk/SKAttachmentEmailer.h
===================================================================
--- trunk/SKAttachmentEmailer.h 2012-11-03 23:47:04 UTC (rev 7777)
+++ trunk/SKAttachmentEmailer.h 2012-11-04 00:12:20 UTC (rev 7778)
@@ -52,5 +52,6 @@
 - (void)emailAttachmentFile;
 
 - (void)waitForTaskTermination:(NSTask *)task;
+- (void)taskFailed;
 
 @end

Modified: trunk/SKAttachmentEmailer.m
===================================================================
--- trunk/SKAttachmentEmailer.m 2012-11-03 23:47:04 UTC (rev 7777)
+++ trunk/SKAttachmentEmailer.m 2012-11-04 00:12:20 UTC (rev 7778)
@@ -128,6 +128,7 @@
 - (void)taskFinished:(NSNotification *)notification {
     if ([[NSFileManager defaultManager] fileExistsAtURL:fileURL] == NO)
         [self emailAttachmentFile];
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
     [self autorelease];
 }
 
@@ -136,4 +137,9 @@
     [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(taskFinished:) name:NSTaskDidTerminateNotification 
object:task];
 }
 
+- (void)taskFailed {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    [self autorelease];
+}
+
 @end

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2012-11-03 23:47:04 UTC (rev 7777)
+++ trunk/SKMainDocument.m      2012-11-04 00:12:20 UTC (rev 7778)
@@ -1137,10 +1137,16 @@
     [task setArguments:[NSArray arrayWithObjects:@"-czf", [fileURL path], 
[[self fileURL] lastPathComponent], nil]];
     [task setCurrentDirectoryPath:[[[self fileURL] 
URLByDeletingLastPathComponent] path]];
     
+    SKAttachmentEmailer *emailer = nil;
     if (email)
-        [SKAttachmentEmailer attachmentEmailerWithFileURL:fileURL 
subject:[self displayName] waitingForTask:task];
+        emailer = [SKAttachmentEmailer attachmentEmailerWithFileURL:fileURL 
subject:[self displayName] waitingForTask:task];
     
-    [task launch];
+    @try {
+        [task launch];
+    }
+    @catch (id exception) {
+        [emailer taskFailed];
+    }
 }
 
 - (IBAction)saveArchive:(id)sender {
@@ -1178,10 +1184,16 @@
     [task setArguments:[NSArray arrayWithObjects:@"create", @"-srcfolder", 
[[self fileURL] path], @"-format", @"UDZO", @"-volname", [[fileURL 
lastPathComponent] stringByDeletingPathExtension], [fileURL path], nil]];
     [task setCurrentDirectoryPath:[[[self fileURL] 
URLByDeletingLastPathComponent] path]];
     
+    SKAttachmentEmailer *emailer = nil;
     if (email)
-        [SKAttachmentEmailer attachmentEmailerWithFileURL:fileURL 
subject:[self displayName] waitingForTask:task];
+        emailer = [SKAttachmentEmailer attachmentEmailerWithFileURL:fileURL 
subject:[self displayName] waitingForTask:task];
     
-    [task launch];
+    @try {
+        [task launch];
+    }
+    @catch (id exception) {
+        [emailer taskFailed];
+    }
 }
 
 - (IBAction)saveDiskImage:(id)sender {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to