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

Unified Diff: third_party/sqlite/amalgamation/sqlite3.c

Side-by-side diff isn't available for this file because of its large size.
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:
Download patch
Index: third_party/sqlite/amalgamation/sqlite3.c
===================================================================
--- third_party/sqlite/amalgamation/sqlite3.c (revision 86429)
+++ third_party/sqlite/amalgamation/sqlite3.c (working copy)
@@ -7647,6 +7647,11 @@
#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */
/*
+** The string appended to the database file name giving the journal file name.
+*/
+const char kPagerJournalSuffix[] = "-journal\0";
+
+/*
** The remainder of this file contains the declarations of the functions
** that make up the Pager sub-system API. See source code comments for
** a detailed description of each routine.
@@ -34525,7 +34530,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);
}
@@ -35293,6 +35299,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
@@ -35358,6 +35369,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) );
}
@@ -104710,7 +104753,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
};
@@ -104734,7 +104777,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);
}
@@ -104743,7 +104786,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