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

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, 6 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/sqliteInt.h
2 ===================================================================
3 --- src/sqliteInt.h (revision 87026)
4 +++ src/sqliteInt.h (working copy)
5 @@ -2522,6 +2522,16 @@
6 #endif
7
8 /*
9 +** The CoreServices.h and CoreFoundation.h headers are needed for excluding a
10 +** -journal file from Time Machine backups when its associated database has
11 +** previously been excluded by the client code.
12 +*/
13 +#if defined(__APPLE__)
14 +#include <CoreServices/CoreServices.h>
15 +#include <CoreFoundation/CoreFoundation.h>
16 +#endif
17 +
18 +/*
19 ** The following macros mimic the standard library functions toupper(),
20 ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
21 ** sqlite versions only work for ASCII characters, regardless of locale.
22 Index: src/pager.c
23 ===================================================================
24 --- src/pager.c (revision 87026)
25 +++ src/pager.c (working copy)
26 @@ -429,6 +429,11 @@
27 #define MAX_SECTOR_SIZE 0x10000
28
29 /*
30 +** The string appended to the database file name giving the journal file name.
31 +*/
32 +static const char kPagerJournalSuffix[] = "-journal";
33 +
34 +/*
35 ** An instance of the following structure is allocated for each active
36 ** savepoint and statement transaction in the system. All such structures
37 ** are stored in the Pager.aSavepoint[] array, which is allocated and
38 @@ -4404,9 +4409,10 @@
39 pPager->zJournal = (char*)(pPtr += nPathname + 1);
40 memcpy(pPager->zFilename, zPathname, nPathname);
41 memcpy(pPager->zJournal, zPathname, nPathname);
42 - memcpy(&pPager->zJournal[nPathname], "-journal", 8);
43 + memcpy(&pPager->zJournal[nPathname], kPagerJournalSuffix,
44 + strlen(kPagerJournalSuffix));
45 #ifndef SQLITE_OMIT_WAL
46 - pPager->zWal = &pPager->zJournal[nPathname+8+1];
47 + pPager->zWal = &pPager->zJournal[nPathname+strlen(kPagerJournalSuffix)+1];
48 memcpy(pPager->zWal, zPathname, nPathname);
49 memcpy(&pPager->zWal[nPathname], "-wal", 4);
50 #endif
51 @@ -5130,7 +5136,21 @@
52 }
53 }
54
55 +#if defined(__APPLE__)
56 /*
57 +** Create and return a CFURLRef given a cstring containing the path to a file.
58 +*/
59 +static CFURLRef create_cfurl_from_cstring(const char* file_path){
60 + CFString url_string = CFStringCreateWithFileSystemRepresentation(
61 + kCFAllocatorDefault, file_path);
62 + CFURLRef url_ref = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
63 + url_string, kCFURLPOSIXPathStyle, FALSE);
64 + CFRelease(url_string);
65 + return url_ref;
66 +}
67 +#endif
68 +
69 +/*
70 ** This function is called at the start of every write transaction.
71 ** There must already be a RESERVED or EXCLUSIVE lock on the database
72 ** file when this routine is called.
73 @@ -5189,6 +5209,22 @@
74 #else
75 rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0);
76 #endif
77 +#if defined(__APPLE__)
78 + // Set the TimeMachine exclusion metadata for the journal if it has
79 + // been set for the database.
80 + if( rc == SQLITE_OK && pPager->zJournal ){
81 + int database_path_size = strlen(pPager->zJournal)
82 + - strlen(kPagerJournalSuffix) + 1;
83 + CFURLRef database_url = create_cfurl_from_cstring(pPager->zFilename);
84 + if( CSBackupIsItemExcluded(database_url, NULL) ){
85 + CFURLRef journal_url = create_cfurl_from_cstring(pPager->zJournal);
86 + // Ignore errors from the following exclusion call.
87 + CSBackupSetItemExcluded(journal_url, TRUE, FALSE);
88 + CFRelease(journal_url);
89 + }
90 + CFRelease(database_url);
91 + }
92 +#endif
93 }
94 assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
95 }
96 Index: ext/fts3/fts3_porter.c
97 ===================================================================
98 --- ext/fts3/fts3_porter.c (revision 87026)
99 +++ ext/fts3/fts3_porter.c (working copy)
100 @@ -129,7 +129,7 @@
101 /*
102 ** Vowel or consonant
103 */
104 -static const char cType[] = {
105 +static const char vOrCType[] = {
106 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,
107 1, 1, 1, 2, 1
108 };
109 @@ -153,7 +153,7 @@
110 char x = *z;
111 if( x==0 ) return 0;
112 assert( x>='a' && x<='z' );
113 - j = cType[x-'a'];
114 + j = vOrCType[x-'a'];
115 if( j<2 ) return j;
116 return z[1]==0 || isVowel(z + 1);
117 }
118 @@ -162,7 +162,7 @@
119 char x = *z;
120 if( x==0 ) return 0;
121 assert( x>='a' && x<='z' );
122 - j = cType[x-'a'];
123 + j = vOrCType[x-'a'];
124 if( j<2 ) return 1-j;
125 return isConsonant(z + 1);
126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698