forked from shadowfacts/Tusker
Migrate drafts to new file
This commit is contained in:
parent
0746e12737
commit
6b4223a9d6
|
@ -35,6 +35,17 @@ public class DraftsManager: Codable, ObservableObject {
|
||||||
return DraftsManager()
|
return DraftsManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static func migrate(from url: URL) -> Result<Void, any Error> {
|
||||||
|
do {
|
||||||
|
try? FileManager.default.removeItem(at: archiveURL)
|
||||||
|
try FileManager.default.moveItem(at: url, to: archiveURL)
|
||||||
|
} catch {
|
||||||
|
return .failure(error)
|
||||||
|
}
|
||||||
|
shared = load()
|
||||||
|
return .success(())
|
||||||
|
}
|
||||||
|
|
||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
public required init(from decoder: Decoder) throws {
|
public required init(from decoder: Decoder) throws {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import CoreData
|
||||||
import OSLog
|
import OSLog
|
||||||
import Sentry
|
import Sentry
|
||||||
import UserAccounts
|
import UserAccounts
|
||||||
|
import ComposeUI
|
||||||
|
|
||||||
let stateRestorationLogger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "StateRestoration")
|
let stateRestorationLogger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "StateRestoration")
|
||||||
|
|
||||||
|
@ -47,6 +48,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DispatchQueue.global(qos: .userInitiated).async {
|
||||||
|
let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
||||||
|
let oldDraftsFile = documentsDirectory.appendingPathComponent("drafts").appendingPathExtension("plist")
|
||||||
|
if FileManager.default.fileExists(atPath: oldDraftsFile.path) {
|
||||||
|
if case .failure(let error) = DraftsManager.migrate(from: oldDraftsFile) {
|
||||||
|
SentrySDK.capture(error: error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue