mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Storage location change (#404)
* Remove LegacyRestorationToken and handling * Fixes #389 - Migrate and store session data in Application Support instead of Caches
This commit is contained in:
@@ -35,12 +35,17 @@ extension URL {
|
||||
|
||||
/// The base directory where all session data is stored.
|
||||
static var sessionsBaseDirectory: URL {
|
||||
let url = cacheBaseDirectory
|
||||
.appendingPathComponent("Sessions", isDirectory: true)
|
||||
let cacheSessionsURL = cacheBaseDirectory.appendingPathComponent("Sessions", isDirectory: true)
|
||||
let applicationSupportSessionsURL = applicationSupportBaseDirectory.appendingPathComponent("Sessions", isDirectory: true)
|
||||
|
||||
#warning("Migration from caches to application support. Remove this in a couple of releases.")
|
||||
if FileManager.default.directoryExists(at: cacheSessionsURL) {
|
||||
try? FileManager.default.moveItem(at: cacheSessionsURL, to: applicationSupportSessionsURL)
|
||||
}
|
||||
|
||||
try? FileManager.default.createDirectoryIfNeeded(at: url)
|
||||
try? FileManager.default.createDirectoryIfNeeded(at: applicationSupportSessionsURL)
|
||||
|
||||
return url
|
||||
return applicationSupportSessionsURL
|
||||
}
|
||||
|
||||
/// The base directory where all cache is stored.
|
||||
@@ -53,4 +58,24 @@ extension URL {
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
/// The base directory where all application support data is stored.
|
||||
static var applicationSupportBaseDirectory: URL {
|
||||
var url = appGroupContainerDirectory
|
||||
.appendingPathComponent("Library", isDirectory: true)
|
||||
.appendingPathComponent("Application Support", isDirectory: true)
|
||||
.appendingPathComponent(InfoPlistReader.target.baseBundleIdentifier, isDirectory: true)
|
||||
|
||||
try? FileManager.default.createDirectoryIfNeeded(at: url)
|
||||
|
||||
do {
|
||||
var resourceValues = URLResourceValues()
|
||||
resourceValues.isExcludedFromBackup = true
|
||||
try url.setResourceValues(resourceValues)
|
||||
} catch {
|
||||
MXLog.error("Failed excluding Application Support from backups")
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user