Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/sqlite/src/src/pager.c

Issue 6990066: Mac TimeMachine File Exclusions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/sqlite/src/src/pager.c
===================================================================
--- third_party/sqlite/src/src/pager.c (revision 86831)
+++ third_party/sqlite/src/src/pager.c (working copy)
@@ -429,6 +429,11 @@
#define MAX_SECTOR_SIZE 0x10000
/*
+** The string appended to the database file name giving the journal file name.
+*/
+static const char kPagerJournalSuffix[] = "-journal";
+
+/*
** An instance of the following structure is allocated for each active
** savepoint and statement transaction in the system. All such structures
** are stored in the Pager.aSavepoint[] array, which is allocated and
@@ -5130,7 +5135,20 @@
}
}
+#if defined(__APPLE__)
/*
+** Create and return a CFURLRef given a cstring containing the path to a file.
+*/
+static CFURLRef create_cfurl_from_cstring(const char* file_path){
+ CFURLRef url_ref = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
+ CFStringCreateWithFileSystemRepresentation(
Mark Mentovai 2011/05/26 21:23:40 You still leak the CFString created with CFStringC
mrossetti 2011/05/27 17:11:36 Done.
+ kCFAllocatorDefault, file_path),
+ kCFURLPOSIXPathStyle, FALSE);
+ return url_ref;
+}
+#endif
+
+/*
** This function is called at the start of every write transaction.
** There must already be a RESERVED or EXCLUSIVE lock on the database
** file when this routine is called.
@@ -5191,6 +5209,28 @@
#endif
}
assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
+#if defined(__APPLE__)
+ // Set the TimeMachine exclusion metadata for the journal if it has
+ // been set for the database.
+ if( rc == SQLITE_OK && pPager->zJournal ){
Scott Hess - ex-Googler 2011/05/26 21:30:54 && pPager->journalMode!=PAGER_JOURNALMODE_MEMORY .
mrossetti 2011/05/27 17:11:36 Done. Moved up since there is no need to mark it e
+ int database_path_size = strlen(pPager->zJournal)
+ - strlen(kPagerJournalSuffix) + 1;
+ char *database_path = sqlite3Malloc(database_path_size);
+ CFURLRef database_url = NULL;
Mark Mentovai 2011/05/26 21:23:40 No need to initialize this to NULL or anything els
mrossetti 2011/05/27 17:11:36 Done.
+ strlcpy(database_path, pPager->zJournal, database_path_size);
+ database_url = create_cfurl_from_cstring(database_path);
+ sqlite3_free(database_path);
Scott Hess - ex-Googler 2011/05/26 21:30:54 Instead of malloc'ing up a substring, use pPager->
mrossetti 2011/05/27 17:11:36 Done.
+ Boolean exclude_by_path;
Mark Mentovai 2011/05/26 21:23:40 You need to declare this above, with the other dec
Scott Hess - ex-Googler 2011/05/26 21:30:54 C code, needs to be up by database_url, though my
mrossetti 2011/05/27 17:11:36 Done.
mrossetti 2011/05/27 17:11:36 I'm removing it. Previously we discussed not exclu
+ if( CSBackupIsItemExcluded(database_url, &exclude_by_path)
+ && !exclude_by_path){
+ CFURLRef journal_url = create_cfurl_from_cstring(pPager->zJournal);
+ // Ignore errors from the following exclusion call.
+ CSBackupSetItemExcluded(journal_url, TRUE, FALSE);
+ CFRelease(journal_url);
+ }
+ CFRelease(database_url);
+ }
+#endif
}

Powered by Google App Engine
This is Rietveld 408576698