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/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 87026)
+++ third_party/sqlite/amalgamation/sqlite3.c (working copy)
@@ -10871,6 +10871,16 @@
#endif
/*
+** The CoreServices.h and CoreFoundation.h headers are needed for excluding a
+** -journal file from Time Machine backups when its associated database has
+** previously been excluded by the client code.
+*/
+#if defined(__APPLE__)
+#include <CoreServices/CoreServices.h>
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
+/*
** The following macros mimic the standard library functions toupper(),
** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
** sqlite versions only work for ASCII characters, regardless of locale.
@@ -36850,6 +36860,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
@@ -40825,9 +40840,10 @@
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));
#ifndef SQLITE_OMIT_WAL
- pPager->zWal = &pPager->zJournal[nPathname+8+1];
+ pPager->zWal = &pPager->zJournal[nPathname+strlen(kPagerJournalSuffix)+1];
memcpy(pPager->zWal, zPathname, nPathname);
memcpy(&pPager->zWal[nPathname], "-wal", 4);
#endif
@@ -41551,7 +41567,21 @@
}
}
+#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){
+ CFString url_string = CFStringCreateWithFileSystemRepresentation(
+ kCFAllocatorDefault, file_path);
+ CFURLRef url_ref = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
+ url_string, kCFURLPOSIXPathStyle, FALSE);
+ CFRelease(url_string);
+ 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.
@@ -41610,6 +41640,22 @@
#else
rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0);
#endif
+#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 ){
+ int database_path_size = strlen(pPager->zJournal)
+ - strlen(kPagerJournalSuffix) + 1;
+ CFURLRef database_url = create_cfurl_from_cstring(pPager->zFilename);
+ if( CSBackupIsItemExcluded(database_url, NULL) ){
+ 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
}
assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
}
@@ -116631,7 +116677,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
};
@@ -116655,7 +116701,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);
}
@@ -116664,7 +116710,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