Skip to content

Commit

Permalink
Exclude the default GTMSessionFetcher logs directory from iTunes/iClo…
Browse files Browse the repository at this point in the history
…ud backups.

If client apps set a custom logs directory, it will continue to be the
responsibility of the client app to exclude that directory from backups.
  • Loading branch information
thomasvl committed Jul 25, 2018
1 parent 7b7c5ef commit cf921e9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Source/GTMSessionFetcherLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
//
// to begin generating log files.
//
// Log files are put into a folder on the desktop called "GTMHTTPDebugLogs"
// unless another directory is specified with +setLoggingDirectory.
//
// In the iPhone simulator, the default logs location is the user's home
// directory in ~/Library/Application Support. On the iPhone device, the
// default logs location is the application's documents directory on the device.
// Unless explicitly set by the application using +setLoggingDirectory:,
// logs are put into a default directory, located at:
// * macOS: ~/Desktop/GTMHTTPDebugLogs
// * iOS simulator: ~/GTMHTTPDebugLogs (in application sandbox)
// * iOS device: ~/Documents/GTMHTTPDebugLogs (in application sandbox)
//
// Tip: use the Finder's "Sort By Date" to find the most recent logs.
//
Expand All @@ -54,9 +53,15 @@

@interface GTMSessionFetcher (GTMSessionFetcherLogging)

// Note: the default logs directory is ~/Desktop/GTMHTTPDebugLogs; it will be
// created as needed. If a custom directory is set, the directory should
// already exist.
// Note: on macOS the default logs directory is ~/Desktop/GTMHTTPDebugLogs; on
// iOS simulators it will be the ~/GTMHTTPDebugLogs (in the app sandbox); on
// iOS devices it will be in ~/Documents/GTMHTTPDebugLogs (in the app sandbox).
// These directories will be created as needed, and are excluded from backups
// to iCloud and iTunes.
//
// If a custom directory is set, the directory should already exist. It is
// the application's responsibility to exclude any custom directory from
// backups, if desired.
+ (void)setLoggingDirectory:(NSString *)path;
+ (NSString *)loggingDirectory;

Expand Down
6 changes: 6 additions & 0 deletions Source/GTMSessionFetcherLogging.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ + (NSString *)loggingDirectory {
withIntermediateDirectories:YES
attributes:nil
error:NULL];
if (doesFolderExist) {
// The directory has been created. Exclude it from backups.
NSURL *pathURL = [NSURL fileURLWithPath:logsFolderPath isDirectory:YES];
[pathURL setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:NULL];
}
}

if (doesFolderExist) {
// it's there; store it in the global
gLoggingDirectoryPath = [logsFolderPath copy];
Expand Down

0 comments on commit cf921e9

Please sign in to comment.