update existing code to use wrapper API

This commit is contained in:
Sixten Otto
2023-02-20 14:34:33 -07:00
parent 0c31e87483
commit fe9376488f
4 changed files with 8 additions and 16 deletions

View File

@ -543,8 +543,7 @@
}
public static func pathForAudioDirectory(itemID: String) -> URL {
FileManager.default
.urls(for: .documentDirectory, in: .userDomainMask)[0]
URL.om_documentsDirectory
.appendingPathComponent("audio-\(itemID)/")
}

View File

@ -56,8 +56,7 @@ struct SpeechDocument: Decodable {
}
static func audioDirectory(pageId: String) -> URL {
FileManager.default
.urls(for: .documentDirectory, in: .userDomainMask)[0]
URL.om_documentsDirectory
.appendingPathComponent("audio-\(pageId)")
}
}
@ -213,12 +212,10 @@ struct SpeechSynthesizer {
let data = try await downloadData(session: session, request: speechItem.urlRequest)
let tempPath = FileManager.default
.urls(for: .cachesDirectory, in: .userDomainMask)[0]
let tempPath = URL.om_cachesDirectory
.appendingPathComponent(UUID().uuidString + ".mp3")
let tempSMPath = FileManager.default
.urls(for: .cachesDirectory, in: .userDomainMask)[0]
let tempSMPath = URL.om_cachesDirectory
.appendingPathComponent(UUID().uuidString + ".speechMarks")
do {

View File

@ -21,8 +21,7 @@ public extension DataService {
var localPdfURL: URL?
let tempPath = FileManager.default
.urls(for: .cachesDirectory, in: .userDomainMask)[0]
let tempPath = URL.om_cachesDirectory
.appendingPathComponent(UUID().uuidString + ".pdf")
try await backgroundContext.perform { [weak self] in

View File

@ -10,8 +10,7 @@ import QuickLookThumbnailing
public enum PDFUtils {
public static func copyToLocal(url: URL) throws -> String {
let subPath = UUID().uuidString + ".pdf"
let dest = FileManager.default
.urls(for: .documentDirectory, in: .userDomainMask)[0]
let dest = URL.om_documentsDirectory
.appendingPathComponent(subPath)
try FileManager.default.copyItem(at: url, to: dest)
@ -20,8 +19,7 @@ public enum PDFUtils {
public static func moveToLocal(url: URL) throws -> String {
let subPath = UUID().uuidString + ".pdf"
let dest = FileManager.default
.urls(for: .documentDirectory, in: .userDomainMask)[0]
let dest = URL.om_documentsDirectory
.appendingPathComponent(subPath)
try FileManager.default.moveItem(at: url, to: dest)
@ -29,8 +27,7 @@ public enum PDFUtils {
}
public static func localPdfURL(filename: String) -> URL? {
let url = FileManager.default
.urls(for: .documentDirectory, in: .userDomainMask)[0]
let url = URL.om_documentsDirectory
.appendingPathComponent(filename)
return url