mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Merge pull request #5557 from vector-im/andy/5498_icloud_backup
Exclude all items from iCloud backup
This commit is contained in:
commit
438db8af98
5 changed files with 31 additions and 5 deletions
|
@ -61,6 +61,14 @@ class URLPreviewStore {
|
|||
if let error = error {
|
||||
MXLog.error("[URLPreviewStore] Core Data container error: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
if let url = storeDescription.url {
|
||||
do {
|
||||
try FileManager.default.excludeItemFromBackup(at: url)
|
||||
} catch {
|
||||
MXLog.error("[URLPreviewStore] Cannot exclude Core Data from backup: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
import Foundation
|
||||
import Intents
|
||||
import MatrixSDK
|
||||
|
||||
#if DEBUG
|
||||
import FLEX
|
||||
|
@ -79,6 +80,7 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
|
|||
func start() {
|
||||
self.setupLogger()
|
||||
self.setupTheme()
|
||||
self.excludeAllItemsFromBackup()
|
||||
|
||||
// Setup navigation router store
|
||||
_ = NavigationRouterStore.shared
|
||||
|
@ -129,6 +131,17 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
|
|||
}
|
||||
}
|
||||
|
||||
private func excludeAllItemsFromBackup() {
|
||||
let manager = FileManager.default
|
||||
|
||||
// Individual files and directories created by the application or SDK are excluded case-by-case,
|
||||
// but sometimes the lifecycle of a file is not directly controlled by the app (e.g. plists for
|
||||
// UserDefaults). For that reason the app will always exclude all top-level directories as well
|
||||
// as individual files.
|
||||
manager.excludeAllUserDirectoriesFromBackup()
|
||||
manager.excludeAllAppGroupDirectoriesFromBackup()
|
||||
}
|
||||
|
||||
private func showAuthentication() {
|
||||
// TODO: Implement
|
||||
}
|
||||
|
|
|
@ -1873,6 +1873,10 @@ static NSString *contactsBookInfoFile = @"contactsV2";
|
|||
if (error == nil)
|
||||
{
|
||||
[cipher writeToFile:[self dataFilePathForComponent:fileName] atomically:YES];
|
||||
[[NSFileManager defaultManager] excludeItemFromBackupAt:[NSURL fileURLWithPath:fileName] error:&error];
|
||||
if (error) {
|
||||
MXLogDebug(@"[MXKContactManager] Cannot exclude item from backup %@", error.localizedDescription);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#import "MXKAppSettings.h"
|
||||
|
||||
#import "MXKTools.h"
|
||||
@import MatrixSDK;
|
||||
|
||||
|
||||
// get ISO country name
|
||||
|
@ -66,11 +67,10 @@ static NSString *const kMXAppGroupID = @"group.org.matrix";
|
|||
{
|
||||
NSString *cacheFolder;
|
||||
|
||||
// Check for a potential application group id
|
||||
NSString *applicationGroupIdentifier = [MXSDKOptions sharedInstance].applicationGroupIdentifier;
|
||||
if (applicationGroupIdentifier)
|
||||
// Check for a potential application group container
|
||||
NSURL *sharedContainerURL = [[NSFileManager defaultManager] applicationGroupContainerURL];
|
||||
if (sharedContainerURL)
|
||||
{
|
||||
NSURL *sharedContainerURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:applicationGroupIdentifier];
|
||||
cacheFolder = [sharedContainerURL path];
|
||||
}
|
||||
else
|
||||
|
@ -86,7 +86,7 @@ static NSString *const kMXAppGroupID = @"group.org.matrix";
|
|||
if (cacheFolder && ![[NSFileManager defaultManager] fileExistsAtPath:cacheFolder])
|
||||
{
|
||||
NSError *error;
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:cacheFolder withIntermediateDirectories:YES attributes:nil error:&error];
|
||||
[[NSFileManager defaultManager] createDirectoryExcludedFromBackupAtPath:cacheFolder error:&error];
|
||||
if (error)
|
||||
{
|
||||
MXLogDebug(@"[MXKAppSettings] cacheFolder: Error: Cannot create MatrixKit folder at %@. Error: %@", cacheFolder, error);
|
||||
|
|
1
changelog.d/5498.change
Normal file
1
changelog.d/5498.change
Normal file
|
@ -0,0 +1 @@
|
|||
Exclude all files and directories from iCloud and iTunes backup
|
Loading…
Reference in a new issue