Skip to content

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

Merged
merged 4 commits into from
Sep 10, 2020
Merged

Some FileManager extensions #236

merged 4 commits into from
Sep 10, 2020

Conversation

rickpasetto
Copy link

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)

@rickpasetto rickpasetto changed the title ponseRick/filemanager extensions Some FileManager extensions Sep 9, 2020
@@ -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
Copy link
Author

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.

Copy link

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.

Copy link
Author

@rickpasetto rickpasetto Sep 10, 2020

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:

https://stackoverflow.com/questions/36450555/changing-nspersistentstorefileprotectionkey-for-persistent-store-manager-on-exis

Would you like me to double-check before merging this? It'd be easiest to just forge a new app and test it.

Copy link
Author

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.

Copy link

@ps2 ps2 left a 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
Copy link

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.

Rick Pasetto added 2 commits September 10, 2020 10:24
@rickpasetto rickpasetto merged commit 0a36cd5 into dev Sep 10, 2020
@rickpasetto rickpasetto deleted the rick/filemanager-extensions branch September 10, 2020 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants