Chromium Code Reviews| Index: third_party/sqlite/src/src/pager.c |
| =================================================================== |
| --- third_party/sqlite/src/src/pager.c (revision 87026) |
| +++ 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 |
| @@ -4404,9 +4409,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 |
| @@ -5130,7 +5136,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( |
|
Mark Mentovai
2011/05/27 17:20:37
CFStringRef, not CFString.
This wouldn’t even hav
mrossetti
2011/05/27 19:20:35
Yeah, my local build bashed me over the head with
|
| + 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. |
| @@ -5189,6 +5209,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 ){ |
|
Scott Hess - ex-Googler
2011/05/27 17:23:34
In this location, I don't know what it would mean
mrossetti
2011/05/27 19:20:35
Done.
|
| + int database_path_size = strlen(pPager->zJournal) |
| + - strlen(kPagerJournalSuffix) + 1; |
|
Scott Hess - ex-Googler
2011/05/27 17:23:34
database_path_size now unused.
mrossetti
2011/05/27 19:20:35
Done.
|
| + CFURLRef database_url = create_cfurl_from_cstring(pPager->zFilename); |
| + if( CSBackupIsItemExcluded(database_url, NULL) ){ |
|
Mark Mentovai
2011/05/27 17:20:37
As discussed.
|
| + 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) ); |
| } |