mirror of https://github.com/oxen-io/session-ios
Merge branch 'charlesmchen/dontBackupFiles'
commit
7730b78d86
@ -0,0 +1,15 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSFileSystem : NSObject
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
+ (void)protectFolderAtPath:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSFileSystem.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation OWSFileSystem
|
||||
|
||||
+ (void)protectFolderAtPath:(NSString *)path
|
||||
{
|
||||
if (![NSFileManager.defaultManager fileExistsAtPath:path]) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSError *error;
|
||||
NSDictionary *fileProtection = @{ NSFileProtectionKey : NSFileProtectionCompleteUntilFirstUserAuthentication };
|
||||
[[NSFileManager defaultManager] setAttributes:fileProtection ofItemAtPath:path error:&error];
|
||||
|
||||
NSDictionary *resourcesAttrs = @{ NSURLIsExcludedFromBackupKey : @YES };
|
||||
|
||||
NSURL *ressourceURL = [NSURL fileURLWithPath:path];
|
||||
BOOL success = [ressourceURL setResourceValues:resourcesAttrs error:&error];
|
||||
|
||||
if (error || !success) {
|
||||
OWSProdCritical([OWSAnalyticsEvents storageErrorFileProtection]);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
Loading…
Reference in New Issue