mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-01 02:09:32 +00:00
ios: exclude app data from backup (#7623)
Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
co-authored by
Evgeny @ SimpleX Chat
parent
be39a42121
commit
3c0a6f0e29
@@ -123,6 +123,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {
|
||||
|
||||
private func prepareForLaunch() {
|
||||
try? FileManager.default.createDirectory(at: getWallpaperDirectory(), withIntermediateDirectories: true)
|
||||
excludeAppDataFromBackup()
|
||||
}
|
||||
|
||||
static func keepScreenOn(_ on: Bool) {
|
||||
|
||||
@@ -66,6 +66,18 @@ func getAppDirectory() -> URL {
|
||||
: getDocumentsDirectory()
|
||||
}
|
||||
|
||||
public func excludeAppDataFromBackup() {
|
||||
var values = URLResourceValues()
|
||||
values.isExcludedFromBackup = true
|
||||
for var dir in [getGroupContainerDirectory(), getDocumentsDirectory()] {
|
||||
do {
|
||||
try dir.setResourceValues(values)
|
||||
} catch {
|
||||
logger.error("FileUtils.excludeAppDataFromBackup error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spec: spec/database.md#DB_FILE_PREFIX
|
||||
let DB_FILE_PREFIX = "simplex_v1"
|
||||
|
||||
|
||||
@@ -74,6 +74,10 @@ See [`getDocumentsDirectory()`](../SimpleXChat/FileUtils.swift#L47) and [`getGro
|
||||
|
||||
The container choice is stored in `dbContainerGroupDefault` (`GroupDefaults`).
|
||||
|
||||
### Backup Exclusion
|
||||
|
||||
`isExcludedFromBackup` is set on both containers by [`excludeAppDataFromBackup()`](../SimpleXChat/FileUtils.swift#L69-L79), which is called from [`prepareForLaunch()`](../Shared/AppDelegate.swift#L124-L127) on each app launch. Files that the app, NSE and SE create or replace in these directories later are excluded as well.
|
||||
|
||||
---
|
||||
|
||||
## 3. Haskell Store Modules
|
||||
|
||||
Reference in New Issue
Block a user