File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed
App/WebView/DownloadManager Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,11 @@ struct DownloadManagerView: View {
2020 }
2121 . onDisappear {
2222 viewModel. cancelDownload ( )
23- viewModel. deleteFile ( )
23+
24+ // For mac the file should remain in the download folder to keep expected behavior
25+ if !Current. isCatalyst {
26+ viewModel. deleteFile ( )
27+ }
2428 }
2529 . onChange ( of: viewModel. finished) { _, newValue in
2630 if newValue, Current . isCatalyst {
Original file line number Diff line number Diff line change @@ -229,16 +229,28 @@ public enum AppConstants {
229229 }
230230
231231 public static var DownloadsDirectory : URL {
232- let fileManager = FileManager . default
233- let directoryURL = FileManager . default. urls ( for: . cachesDirectory, in: . allDomainsMask) . first!
234- . appendingPathComponent (
232+ var directoryURL : URL = FileManager . default. urls ( for: . cachesDirectory, in: . allDomainsMask) . first!
233+
234+ // Save directly in macOS Downloads folder if running on Catalyst and allowed access to download folder when
235+ // prompted.
236+ if Current . isCatalyst, let macDownloadFolder = FileManager . default. urls (
237+ for: . downloadsDirectory,
238+ in: . userDomainMask
239+ ) . first {
240+ directoryURL = macDownloadFolder
241+ } else {
242+ directoryURL = directoryURL. appendingPathComponent (
235243 " Downloads " ,
236244 isDirectory: true
237245 )
238-
239- if !fileManager . fileExists ( atPath: directoryURL. path) {
246+ }
247+ if !FileManager . default . fileExists ( atPath: directoryURL. path) {
240248 do {
241- try fileManager. createDirectory ( at: directoryURL, withIntermediateDirectories: true , attributes: nil )
249+ try FileManager . default. createDirectory (
250+ at: directoryURL,
251+ withIntermediateDirectories: true ,
252+ attributes: nil
253+ )
242254 } catch {
243255 fatalError ( " Error while attempting to create downloads path URL: \( error) " )
244256 }
You can’t perform that action at this time.
0 commit comments