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

Unified Diff: third_party/sqlite/mac_time_machine.patch

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/mac_time_machine.patch
===================================================================
--- third_party/sqlite/mac_time_machine.patch (revision 0)
+++ third_party/sqlite/mac_time_machine.patch (revision 0)
@@ -0,0 +1,108 @@
+Index: src/pager.c
+===================================================================
+--- src/pager.c (revision 86426)
++++ src/pager.c (working copy)
+@@ -122,6 +122,11 @@
+ #define MAX_SECTOR_SIZE 0x10000
+
+ /*
++** The string appended to the database file name giving the journal file name.
++*/
++const char kPagerJournalSuffix[] = "-journal\0";
++
++/*
+ ** 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
+@@ -3222,7 +3227,8 @@
+ pPager->zJournal = (char*)(pPtr += nPathname + 1);
+ memcpy(pPager->zFilename, zPathname, nPathname);
+ memcpy(pPager->zJournal, zPathname, nPathname);
+- memcpy(&pPager->zJournal[nPathname], "-journal", 8);
++ memcpy(&pPager->zJournal[nPathname], kPagerJournalSuffix,
++ strlen(kPagerJournalSuffix));
+ if( pPager->zFilename[0]==0 ) pPager->zJournal[0] = 0;
+ sqlite3_free(zPathname);
+ }
+@@ -3990,6 +3996,11 @@
+ return rc;
+ }
+
++#if defined(__APPLE__)
++#include <CoreServices/CoreServices.h>
++#include <CoreFoundation/CoreFoundation.h>
++#endif
++
+ /*
+ ** This function is called at the start of every write transaction.
+ ** There must already be a RESERVED or EXCLUSIVE lock on the database
+@@ -4055,6 +4066,38 @@
+ #else
+ rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0);
+ #endif
++#if defined(__APPLE__)
++ if( rc == SQLITE_OK && pPager->zJournal ) {
++ // Set the TimeMachine exclusion metadata for the journal if it has
++ // been set for the database.
++ int database_path_len =
++ strlen(pPager->zJournal) - strlen(kPagerJournalSuffix) + 1;
++ char *database_path = sqlite3Malloc(database_path_len);
++ strlcpy(database_path, pPager->zJournal, database_path_len);
++ CFURLRef database_url =
++ CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
++ CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
++ database_path, kCFStringEncodingMacRoman, kCFAllocatorNull),
++ kCFURLPOSIXPathStyle, false);
++ sqlite3_free(database_path);
++ if( CSBackupIsItemExcluded(database_url, NULL) ){
++ CFURLRef journal_url =
++ CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
++ CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
++ pPager->zJournal, kCFStringEncodingMacRoman,
++ kCFAllocatorNull),
++ kCFURLPOSIXPathStyle, false);
++ OSStatus err = CSBackupSetItemExcluded(journal_url, TRUE, FALSE);
++ CFRelease(journal_url);
++ if( err != noErr ){
++ fprintf(stderr, "CSBackupSetItemExcluded(\"%s\", TRUE, FALSE): %d",
++ pPager->zJournal, (int)err);
++ // DO NOT set rc to an error code -- ignore exclusion errors.
++ }
++ }
++ CFRelease(database_url);
++ }
++#endif
+ }
+ assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
+ }
+Index: ext/fts3/fts3_porter.c
+===================================================================
+--- ext/fts3/fts3_porter.c (revision 86426)
++++ ext/fts3/fts3_porter.c (working copy)
+@@ -126,7 +126,7 @@
+ /*
+ ** Vowel or consonant
+ */
+-static const char cType[] = {
++static const char vOrCType[] = {
+ 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 2, 1
+ };
+@@ -150,7 +150,7 @@
+ char x = *z;
+ if( x==0 ) return 0;
+ assert( x>='a' && x<='z' );
+- j = cType[x-'a'];
++ j = vOrCType[x-'a'];
+ if( j<2 ) return j;
+ return z[1]==0 || isVowel(z + 1);
+ }
+@@ -159,7 +159,7 @@
+ char x = *z;
+ if( x==0 ) return 0;
+ assert( x>='a' && x<='z' );
+- j = cType[x-'a'];
++ j = vOrCType[x-'a'];
+ if( j<2 ) return 1-j;
+ return isConsonant(z + 1);
+ }

Powered by Google App Engine
This is Rietveld 408576698