Skip to content

Commit 87ad99b

Browse files
committed
Either default or custom folder is loaded
1 parent ace3fb7 commit 87ad99b

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

Diff for: OpenGpxTracker/GPXFileManager.swift

+6-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import Foundation
99

10-
1110
///
1211
/// Class to handle actions with GPX files (save, delete, etc..)
1312
///
@@ -34,17 +33,13 @@ class GPXFileManager: NSObject {
3433
/// Gets the list of `.gpx` files in Documents directory ordered by modified date
3534
///
3635
class var fileList: [GPXFileInfo] {
37-
let fileManager = FileManager.default
38-
// Default to app documents directory
39-
var documentsURL = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0]
40-
// If user has a custom folder display the custom folder
41-
if let customFolderURL = Preferences.shared.gpxFilesFolderURL {
42-
documentsURL = customFolderURL
36+
let documentsURL = GPXFileManager.GPXFilesFolderURL
37+
if documentsURL.startAccessingSecurityScopedResource() {
38+
let files = self.fetchFilesList(from: documentsURL)
39+
documentsURL.stopAccessingSecurityScopedResource()
40+
return files
4341
}
44-
_ = documentsURL.startAccessingSecurityScopedResource()
45-
let files = self.fetchFilesList(from: documentsURL)
46-
documentsURL.stopAccessingSecurityScopedResource()
47-
return files
42+
return []
4843
}
4944

5045
///

0 commit comments

Comments
 (0)