Revision: 29527
          http://sourceforge.net/p/bibdesk/svn/29527
Author:   hofman
Date:     2025-09-03 16:52:11 +0000 (Wed, 03 Sep 2025)
Log Message:
-----------
remove existing file at download target location, the user should have 
confirmed to overwrite

Modified Paths:
--------------
    trunk/bibdesk/BDSKDownloadManager.m

Modified: trunk/bibdesk/BDSKDownloadManager.m
===================================================================
--- trunk/bibdesk/BDSKDownloadManager.m 2025-09-03 16:35:24 UTC (rev 29526)
+++ trunk/bibdesk/BDSKDownloadManager.m 2025-09-03 16:52:11 UTC (rev 29527)
@@ -210,7 +210,7 @@
 - (void)downloadDidFinish:(id)download {
     BDSKWebDownload *webDownload = [self webDownloadForDownload:download];
     
-    if ([webDownload response] && [webDownload fileURL]) {
+    if ([webDownload response] && [[webDownload fileURL] 
checkResourceIsReachableAndReturnError:NULL]) {
         // this must be an NSURLDownload, otherwwise there won't be a response
         // move the file when finished, as the delegate method to choose 
beforehand does not work
         NSString *filename = [[webDownload response] suggestedFilename];
@@ -233,6 +233,8 @@
         
         if ([sPanel runModal] == NSModalResponseOK) {
             NSURL *fileURL = [sPanel URL];
+            if ([fileURL checkResourceIsReachableAndReturnError:NULL])
+                [[NSFileManager defaultManager] removeItemAtURL:fileURL 
error:NULL];
             if ([[NSFileManager defaultManager] moveItemAtURL:[webDownload 
fileURL] toURL:fileURL error:NULL])
                 [webDownload setFileURL:fileURL];
         }
@@ -320,6 +322,8 @@
     void (^handler)(NSModalResponse) = ^(NSModalResponse result){
         if (result == NSModalResponseOK) {
             NSURL *fileURL = [sPanel URL];
+            if ([fileURL checkResourceIsReachableAndReturnError:NULL])
+                [[NSFileManager defaultManager] removeItemAtURL:fileURL 
error:NULL];
             completionHandler(fileURL);
             [[self webDownloadForDownload:download] setFileURL:fileURL];
         } else {

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to