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:
Evgeny
2026-09-30 08:23:51 +01:00
committed by GitHub
co-authored by Evgeny @ SimpleX Chat
parent be39a42121
commit 3c0a6f0e29
3 changed files with 17 additions and 0 deletions
+1
View File
@@ -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) {
+12
View File
@@ -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"
+4
View File
@@ -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