Chromium Code Reviews| 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 |
| } |