Generate first feed pages, images
This commit is contained in:
@ -85,47 +85,20 @@ final class Content: ObservableObject {
|
||||
return
|
||||
}
|
||||
|
||||
try? storage.update(baseFolder: URL(filePath: contentPath), moveContent: false)
|
||||
try? storage.update(baseFolder: URL(filePath: contentPath))
|
||||
observeContentPath()
|
||||
}
|
||||
|
||||
private func observeContentPath() {
|
||||
$contentPath.sink { newValue in
|
||||
let url = URL(filePath: newValue)
|
||||
try? self.storage.update(baseFolder: url, moveContent: true)
|
||||
do {
|
||||
try self.storage.update(baseFolder: url)
|
||||
try self.loadFromDisk()
|
||||
} catch {
|
||||
print("Failed to switch content path: \(error)")
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
// MARK: Folder access
|
||||
|
||||
static func accessFolderFromBookmark(key: String, operation: (URL) -> Void) {
|
||||
guard let bookmarkData = UserDefaults.standard.data(forKey: key) else {
|
||||
print("No bookmark data to access folder")
|
||||
return
|
||||
}
|
||||
var isStale = false
|
||||
let folderURL: URL
|
||||
do {
|
||||
// Resolve the bookmark to get the folder URL
|
||||
folderURL = try URL(resolvingBookmarkData: bookmarkData, options: .withSecurityScope, relativeTo: nil, bookmarkDataIsStale: &isStale)
|
||||
} catch {
|
||||
print("Failed to resolve bookmark: \(error)")
|
||||
return
|
||||
}
|
||||
|
||||
if isStale {
|
||||
print("Bookmark is stale, consider saving a new bookmark.")
|
||||
}
|
||||
|
||||
// Start accessing the security-scoped resource
|
||||
if folderURL.startAccessingSecurityScopedResource() {
|
||||
print("Accessing folder: \(folderURL.path)")
|
||||
|
||||
operation(folderURL)
|
||||
folderURL.stopAccessingSecurityScopedResource()
|
||||
} else {
|
||||
print("Failed to access folder: \(folderURL.path)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user