-
Notifications
You must be signed in to change notification settings - Fork 4
Some FileManager extensions #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -161,8 +159,7 @@ public final class PersistenceController { | |||
options: [ | |||
NSMigratePersistentStoresAutomaticallyOption: true, | |||
NSInferMappingModelAutomaticallyOption: true, | |||
// Data should be available on reboot before first unlock | |||
NSPersistentStoreFileProtectionKey: FileProtectionType.none | |||
NSPersistentStoreFileProtectionKey: FileProtectionType.completeUntilFirstUserAuthentication |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also changes the default data protection of the .sqlite file. After perusing the documentation, I'm not sure what CoreData does if you change the NSPersistentStoreFileProtectionKey
. One hopes it does something like the extension above does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm not sure. If we really wanted to migrate the protection levels of existing files, I'm guessing we'd have to do more than just this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ps2 Maybe. This SO post (admittedly it's weak evidence) seems to indicate that CoreData handles this:
Would you like me to double-check before merging this? It'd be easiest to just forge a new app and test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ps2 I have written a sample app to test the theory about whether CoreData automatically updates the file protection mode, and I have convinced myself it does. If you want details, I'd be happy to share them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This needs testing, for sure, with existing db files.
@@ -161,8 +159,7 @@ public final class PersistenceController { | |||
options: [ | |||
NSMigratePersistentStoresAutomaticallyOption: true, | |||
NSInferMappingModelAutomaticallyOption: true, | |||
// Data should be available on reboot before first unlock | |||
NSPersistentStoreFileProtectionKey: FileProtectionType.none | |||
NSPersistentStoreFileProtectionKey: FileProtectionType.completeUntilFirstUserAuthentication |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm not sure. If we really wanted to migrate the protection levels of existing files, I'm guessing we'd have to do more than just this.
# Conflicts: # LoopKit/Persistence/PersistenceController.swift
In response to some feedback from tidepool-org/Loop#247, I've consolidated some of the handier functions in a
FileManager
extension for use elsewhere.(Note: this actually fixes a minor bug in
PersistenceController
:fileExists
takes a path not a URL string)