Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Account for missing NSFileProtectionKey file attribute key. #235

Closed
wants to merge 5 commits into from

4 participants

@DuneParkSoftware

Ok, after doing a bit of testing, it appears that the NSFileProtectedKey is not included in the file attributes dictionary while running on the iOS simulator. It does get returned on a device, however. I tested on iOS 7.0.6.

When the key is missing, it forces a new log file to always be created, due to the test if (! [key isEqualToString:NSFileProtectionCompleteUntilFirstUserAuthentication]) { near line ~946.

Therefore, this patch will assume that we can reuse the existing log file if the NSFileProtectedKey is missing. If you're not comfortable with this, we could add checks for #if TARGET_IPHONE_SIMULATOR to fine-tune this condition.

Thanks!

@bpoplauschi
Collaborator

@dvor can you please take a look at this?

@dvor
Collaborator

I'm not sure if this is right fix. The problem is that on iOS simulator all attributes are reset on every launch. That's why we need .archived extension for simulator only.

I'll take a look at this problem as soon as I'll have some free time.

@bpoplauschi
Collaborator

Thanks mate.

@rivera-ernesto
Collaborator

Because of #238 this pull request will need a small update (details).

@dvor dvor was assigned by rivera-ernesto
@rivera-ernesto
Collaborator

@DuneParkSoftware Could you update this pull request?

@DuneParkSoftware

Thanks everyone!

@rivera-ernesto
Collaborator

I think you can just reopen this and append a commit to fix the merge conflict.

@bpoplauschi bpoplauschi added this to the 1.9.0 milestone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 5 deletions.
  1. +9 −5 Lumberjack/DDFileLogger.m
View
14 Lumberjack/DDFileLogger.m
@@ -936,11 +936,15 @@ - (DDLogFileInfo *)currentLogFileInfo
// a new one.
if (useExistingLogFile && doesAppRunInBackground()) {
- NSString *key = mostRecentLogFileInfo.fileAttributes[NSFileProtectionKey];
-
- if (! [key isEqualToString:NSFileProtectionCompleteUntilFirstUserAuthentication]) {
- useExistingLogFile = NO;
- shouldArchiveMostRecent = YES;
+ // The NSFileProtectionKey is not returned in the file attributes dictionary when running in the iOS
+ // simulator. Therefore, resume the previous log file if NSFileProtectionKey is not specified.
+ if ([mostRecentLogFileInfo.fileAttributes.allKeys containsObject:NSFileProtectionKey]) {
+ NSString *key = mostRecentLogFileInfo.fileAttributes[NSFileProtectionKey];
+
+ if (! [key isEqualToString:NSFileProtectionCompleteUntilFirstUserAuthentication]) {
+ useExistingLogFile = NO;
+ shouldArchiveMostRecent = YES;
+ }
}
}
#endif
Something went wrong with that request. Please try again.