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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 Index: src/pager.c
2 ===================================================================
3 --- src/pager.c (revision 86426)
4 +++ src/pager.c (working copy)
5 @@ -122,6 +122,11 @@
6 #define MAX_SECTOR_SIZE 0x10000
7
8 /*
9 +** The string appended to the database file name giving the journal file name.
10 +*/
11 +const char kPagerJournalSuffix[] = "-journal\0";
12 +
13 +/*
14 ** An instance of the following structure is allocated for each active
15 ** savepoint and statement transaction in the system. All such structures
16 ** are stored in the Pager.aSavepoint[] array, which is allocated and
17 @@ -3222,7 +3227,8 @@
18 pPager->zJournal = (char*)(pPtr += nPathname + 1);
19 memcpy(pPager->zFilename, zPathname, nPathname);
20 memcpy(pPager->zJournal, zPathname, nPathname);
21 - memcpy(&pPager->zJournal[nPathname], "-journal", 8);
22 + memcpy(&pPager->zJournal[nPathname], kPagerJournalSuffix,
23 + strlen(kPagerJournalSuffix));
24 if( pPager->zFilename[0]==0 ) pPager->zJournal[0] = 0;
25 sqlite3_free(zPathname);
26 }
27 @@ -3990,6 +3996,11 @@
28 return rc;
29 }
30
31 +#if defined(__APPLE__)
32 +#include <CoreServices/CoreServices.h>
33 +#include <CoreFoundation/CoreFoundation.h>
34 +#endif
35 +
36 /*
37 ** This function is called at the start of every write transaction.
38 ** There must already be a RESERVED or EXCLUSIVE lock on the database
39 @@ -4055,6 +4066,38 @@
40 #else
41 rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0);
42 #endif
43 +#if defined(__APPLE__)
44 + if( rc == SQLITE_OK && pPager->zJournal ) {
45 + // Set the TimeMachine exclusion metadata for the journal if it has
46 + // been set for the database.
47 + int database_path_len =
48 + strlen(pPager->zJournal) - strlen(kPagerJournalSuffix) + 1;
49 + char *database_path = sqlite3Malloc(database_path_len);
50 + strlcpy(database_path, pPager->zJournal, database_path_len);
51 + CFURLRef database_url =
52 + CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
53 + CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
54 + database_path, kCFStringEncodingMacRoman, kCFAllocatorNull) ,
55 + kCFURLPOSIXPathStyle, false);
56 + sqlite3_free(database_path);
57 + if( CSBackupIsItemExcluded(database_url, NULL) ){
58 + CFURLRef journal_url =
59 + CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
60 + CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
61 + pPager->zJournal, kCFStringEncodingMacRoman,
62 + kCFAllocatorNull),
63 + kCFURLPOSIXPathStyle, false);
64 + OSStatus err = CSBackupSetItemExcluded(journal_url, TRUE, FALSE);
65 + CFRelease(journal_url);
66 + if( err != noErr ){
67 + fprintf(stderr, "CSBackupSetItemExcluded(\"%s\", TRUE, FALSE): %d",
68 + pPager->zJournal, (int)err);
69 + // DO NOT set rc to an error code -- ignore exclusion errors.
70 + }
71 + }
72 + CFRelease(database_url);
73 + }
74 +#endif
75 }
76 assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
77 }
78 Index: ext/fts3/fts3_porter.c
79 ===================================================================
80 --- ext/fts3/fts3_porter.c (revision 86426)
81 +++ ext/fts3/fts3_porter.c (working copy)
82 @@ -126,7 +126,7 @@
83 /*
84 ** Vowel or consonant
85 */
86 -static const char cType[] = {
87 +static const char vOrCType[] = {
88 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,
89 1, 1, 1, 2, 1
90 };
91 @@ -150,7 +150,7 @@
92 char x = *z;
93 if( x==0 ) return 0;
94 assert( x>='a' && x<='z' );
95 - j = cType[x-'a'];
96 + j = vOrCType[x-'a'];
97 if( j<2 ) return j;
98 return z[1]==0 || isVowel(z + 1);
99 }
100 @@ -159,7 +159,7 @@
101 char x = *z;
102 if( x==0 ) return 0;
103 assert( x>='a' && x<='z' );
104 - j = cType[x-'a'];
105 + j = vOrCType[x-'a'];
106 if( j<2 ) return 1-j;
107 return isConsonant(z + 1);
108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698