fix: use compatible atomic replacement API
This commit is contained in:
@@ -53,7 +53,13 @@ class LocalStorageManager {
|
|||||||
let tmpURL = fileURL.appendingPathExtension("tmp")
|
let tmpURL = fileURL.appendingPathExtension("tmp")
|
||||||
try data.write(to: tmpURL, options: .atomic)
|
try data.write(to: tmpURL, options: .atomic)
|
||||||
if FileManager.default.fileExists(atPath: fileURL.path) {
|
if FileManager.default.fileExists(atPath: fileURL.path) {
|
||||||
try FileManager.default.replaceItem(at: fileURL, withItemAt: tmpURL)
|
try FileManager.default.replaceItem(
|
||||||
|
at: fileURL,
|
||||||
|
withItemAt: tmpURL,
|
||||||
|
backupItemName: nil,
|
||||||
|
options: [],
|
||||||
|
resultingItemURL: nil
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
try FileManager.default.moveItem(at: tmpURL, to: fileURL)
|
try FileManager.default.moveItem(at: tmpURL, to: fileURL)
|
||||||
}
|
}
|
||||||
@@ -201,7 +207,13 @@ class LocalStorageManager {
|
|||||||
let tmpURL = fileURL.appendingPathExtension("tmp")
|
let tmpURL = fileURL.appendingPathExtension("tmp")
|
||||||
try data.write(to: tmpURL, options: .atomic)
|
try data.write(to: tmpURL, options: .atomic)
|
||||||
if FileManager.default.fileExists(atPath: fileURL.path) {
|
if FileManager.default.fileExists(atPath: fileURL.path) {
|
||||||
try FileManager.default.replaceItem(at: fileURL, withItemAt: tmpURL)
|
try FileManager.default.replaceItem(
|
||||||
|
at: fileURL,
|
||||||
|
withItemAt: tmpURL,
|
||||||
|
backupItemName: nil,
|
||||||
|
options: [],
|
||||||
|
resultingItemURL: nil
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
try FileManager.default.moveItem(at: tmpURL, to: fileURL)
|
try FileManager.default.moveItem(at: tmpURL, to: fileURL)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user