Revision: 2662
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2662&view=rev
Author:   hofman
Date:     2007-08-15 06:13:44 -0700 (Wed, 15 Aug 2007)

Log Message:
-----------
Resume download restarts when there is no resume data or the download failed. 
Allows reloading for restored internet connection. 

Modified Paths:
--------------
    trunk/SKDownload.m

Modified: trunk/SKDownload.m
===================================================================
--- trunk/SKDownload.m  2007-08-14 18:22:41 UTC (rev 2661)
+++ trunk/SKDownload.m  2007-08-15 13:13:44 UTC (rev 2662)
@@ -195,6 +195,7 @@
         progressIndicator = [[NSProgressIndicator alloc] init];
         [progressIndicator setStyle:NSProgressIndicatorBarStyle];
         [progressIndicator setControlSize:NSSmallControlSize];
+        [progressIndicator setUsesThreadedAnimation:YES];
         [progressIndicator sizeToFit];
         if (expectedContentLength > 0) {
             [progressIndicator setIndeterminate:NO];
@@ -239,14 +240,27 @@
 - (void)resumeDownload {
     if ([self canResume]) {
         
-        NSData *resumeData = [[[URLDownload resumeData] retain] autorelease];
+        NSData *resumeData = nil;
+        if ([self status] == SKDownloadStatusCanceled) 
+            resumeData = [[[URLDownload resumeData] retain] autorelease];
+        
         if (resumeData) {
+            
             [URLDownload release];
             URLDownload = [[NSURLDownload alloc] initWithResumeData:resumeData 
delegate:self path:[self filePath]];
             [URLDownload setDeletesFileUponFailure:NO];
             [self setStatus:SKDownloadStatusDownloading];
             if ([delegate respondsToSelector:@selector(downloadDidUpdate:)])
                 [delegate downloadDidUpdate:self];
+            
+        } else {
+            
+            [self cleanupDownload];
+            [self setFilePath:nil];
+            [URLDownload release];
+            URLDownload = nil;
+            [self startDownload];
+            
         }
     }
 }
@@ -262,7 +276,7 @@
 }
 
 - (BOOL)canResume {
-    return [self status] == SKDownloadStatusCanceled;
+    return ([self status] == SKDownloadStatusCanceled || [self status] == 
SKDownloadStatusFailed) && [self URL];
 }
 
 #pragma mark NSURLDownloadDelegate protocol


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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to