Revision: 29992
          http://sourceforge.net/p/bibdesk/svn/29992
Author:   hofman
Date:     2026-02-15 16:25:56 +0000 (Sun, 15 Feb 2026)
Log Message:
-----------
set downloads directory in save panel when it exists

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

Modified: trunk/bibdesk/BDSKItemDownload.m
===================================================================
--- trunk/bibdesk/BDSKItemDownload.m    2026-02-15 16:14:39 UTC (rev 29991)
+++ trunk/bibdesk/BDSKItemDownload.m    2026-02-15 16:25:56 UTC (rev 29992)
@@ -102,12 +102,14 @@
 - (void)download:(BDSKDownload *)aDownload 
decideDestinationWithSuggestedFilename:(NSString *)destinationName 
completionHandler:(void (^)(NSURL *destinationURL))completionHandler {
     NSString *extension = [destinationName pathExtension];
     NSString *downloadsDirectory = [[[NSUserDefaults standardUserDefaults] 
stringForKey:BDSKDownloadsDirectoryKey] stringByExpandingTildeInPath];
-    BOOL isDir;
     
     if (downloadsDirectory == nil)
         downloadsDirectory = [[[NSFileManager defaultManager] 
downloadFolderURL] path];
     
-    if ([NSString isEmptyString:extension] == NO && [[NSFileManager 
defaultManager] fileExistsAtPath:downloadsDirectory isDirectory:&isDir] && 
isDir) {
+    BOOL isDir;
+    BOOL downloadsDirExists = [[NSFileManager defaultManager] 
fileExistsAtPath:downloadsDirectory isDirectory:&isDir] && isDir;
+    
+    if ([NSString isEmptyString:extension] == NO && downloadsDirExists) {
         NSURL *destURL = [NSURL fileURLWithPath:[downloadsDirectory 
stringByAppendingPathComponent:destinationName] isDirectory:NO];
         if (destURL == nil)
             destURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() 
stringByAppendingPathComponent:destinationName]];
@@ -117,11 +119,13 @@
         completionHandler(destURL);
     } else {
         NSSavePanel *savePanel = [NSSavePanel savePanel];
-        if (NO == [extension isEqualToString:@""])
+        if ([NSString isEmptyString:extension] == NO)
             [savePanel setAllowedFileTypes:@[extension]];
         [savePanel setAllowsOtherFileTypes:YES];
         [savePanel setCanSelectHiddenExtension:YES];
         [savePanel setNameFieldStringValue:destinationName];
+        if (downloadsDirExists)
+            [savePanel setDirectoryURL:[NSURL 
fileURLWithPath:downloadsDirectory isDirectory:YES]];
         void (^handler)(NSModalResponse) = ^(NSModalResponse result){
             NSURL *destURL = result == NSModalResponseOK ? [savePanel URL] : 
nil;
             if (destURL == nil)

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

Reply via email to