Revision: 29986
http://sourceforge.net/p/bibdesk/svn/29986
Author: hofman
Date: 2026-02-13 17:56:28 +0000 (Fri, 13 Feb 2026)
Log Message:
-----------
set temporary destination location for WebDownload in tempFileURL. Set fileURL
of download object from generic decideDestination method
Modified Paths:
--------------
trunk/bibdesk/BDSKDownloadManager.m
Modified: trunk/bibdesk/BDSKDownloadManager.m
===================================================================
--- trunk/bibdesk/BDSKDownloadManager.m 2026-02-13 10:12:21 UTC (rev 29985)
+++ trunk/bibdesk/BDSKDownloadManager.m 2026-02-13 17:56:28 UTC (rev 29986)
@@ -263,13 +263,15 @@
void (^handler)(NSModalResponse) = ^(NSModalResponse result){
NSURL *fileURL = nil;
if (result == NSModalResponseOK) {
+ BDSKWebDownload *webDownload = [self
webDownloadForDownload:download];
fileURL = [sPanel URL];
// if a file exists, the user should have confirmed to overwrite
if ([fileURL checkResourceIsReachableAndReturnError:NULL]) {
NSURL *tmpURL = [[NSFileManager defaultManager]
temporaryFileURLWithBasename:[fileURL lastPathComponent]];
if ([[NSFileManager defaultManager] moveItemAtURL:fileURL
toURL:tmpURL error:NULL])
- [[self webDownloadForDownload:download]
setTempFileURL:tmpURL];
+ [webDownload setTempFileURL:tmpURL];
}
+ [webDownload setFileURL:fileURL];
}
completionHandler(fileURL);
};
@@ -387,19 +389,21 @@
filename = disposition;
}
+ NSURL *tmpFileURL = [webDownload tempFileURL];
+ [webDownload setTempFileURL:nil];
+
[downloadManager download:download
decideDestinationWithSuggestedFilename:filename modalForWindow:nil
completionHandler:^(NSURL *destinationURL){
NSError *error = nil;
- if (destinationURL) {
- [[NSFileManager defaultManager] moveItemAtURL:[webDownload
fileURL] toURL:destinationURL error:&error];
- [webDownload setFileURL:destinationURL];
- } else {
+ if (destinationURL)
+ [[NSFileManager defaultManager] moveItemAtURL:tmpFileURL
toURL:destinationURL error:&error];
+ else
error = [NSError errorWithDomain:NSURLErrorDomain
code:NSURLErrorCancelled userInfo:nil];
- }
[downloadManager download:download didCompleteWithError:error];
}];
}
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error {
+ [[downloadManager webDownloadForDownload:download] setTempFileURL:nil];
[downloadManager download:download didCompleteWithError:error];
}
@@ -412,7 +416,7 @@
// and when running a modal save panel the destination is ignored
- (void)download:(NSURLDownload *)download didCreateDestination:(NSString
*)path {
- [[downloadManager webDownloadForDownload:download] setFileURL:[NSURL
fileURLWithPath:path isDirectory:NO]];
+ [[downloadManager webDownloadForDownload:download] setTempFileURL:[NSURL
fileURLWithPath:path isDirectory:NO]];
}
- (BOOL)download:(NSURLDownload *)download
shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType {
@@ -434,11 +438,7 @@
}
- (void)download:(WKDownload *)download
decideDestinationUsingResponse:(NSURLResponse *)response
suggestedFilename:(NSString *)filename completionHandler:(void (^)(NSURL *
destinationURL))completionHandler API_AVAILABLE(macos(11.3)) {
- [downloadManager download:download
decideDestinationWithSuggestedFilename:filename modalForWindow:[[download
webView] window] completionHandler:^(NSURL *destinationURL){
- if (destinationURL)
- [[downloadManager webDownloadForDownload:download]
setFileURL:destinationURL];
- completionHandler(destinationURL);
- }];
+ [downloadManager download:download
decideDestinationWithSuggestedFilename:filename modalForWindow:[[download
webView] window] completionHandler:completionHandler];
}
- (void)download:(WKDownload *)download
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition,
NSURLCredential *))completionHandler API_AVAILABLE(macos(11.3)) {
@@ -456,11 +456,7 @@
}
- (void)download:(BDSKDownload *)download
decideDestinationWithSuggestedFilename:(NSString *)filename
completionHandler:(void (^)(NSURL *destinationURL))completionHandler {
- [downloadManager download:download
decideDestinationWithSuggestedFilename:filename modalForWindow:nil
completionHandler:^(NSURL *destinationURL) {
- if (destinationURL)
- [[downloadManager webDownloadForDownload:download]
setFileURL:destinationURL];
- completionHandler(destinationURL);
- }];
+ [downloadManager download:download
decideDestinationWithSuggestedFilename:filename modalForWindow:nil
completionHandler:completionHandler];
}
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit