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

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 86831)
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 86831)
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 @@ -5130,7 +5135,20 @@
39 }
40 }
41
42 +#if defined(__APPLE__)
43 /*
44 +** Create and return a CFURLRef given a cstring containing the path to a file.
45 +*/
46 +static CFURLRef create_cfurl_from_cstring(const char* file_path){
47 + CFURLRef url_ref = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
48 + CFStringCreateWithFileSystemRepresentation(
49 + kCFAllocatorDefault, file_path),
50 + kCFURLPOSIXPathStyle, FALSE);
51 + return url_ref;
52 +}
53 +#endif
54 +
55 +/*
56 ** This function is called at the start of every write transaction.
57 ** There must already be a RESERVED or EXCLUSIVE lock on the database
58 ** file when this routine is called.
59 @@ -5191,6 +5209,28 @@
60 #endif
61 }
62 assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
63 +#if defined(__APPLE__)
64 + // Set the TimeMachine exclusion metadata for the journal if it has
65 + // been set for the database.
66 + if( rc == SQLITE_OK && pPager->zJournal ){
67 + int database_path_size = strlen(pPager->zJournal)
68 + - strlen(kPagerJournalSuffix) + 1;
69 + char *database_path = sqlite3Malloc(database_path_size);
70 + CFURLRef database_url = NULL;
71 + strlcpy(database_path, pPager->zJournal, database_path_size);
72 + database_url = create_cfurl_from_cstring(database_path);
73 + sqlite3_free(database_path);
74 + Boolean exclude_by_path;
75 + if( CSBackupIsItemExcluded(database_url, &exclude_by_path)
76 + && !exclude_by_path){
77 + CFURLRef journal_url = create_cfurl_from_cstring(pPager->zJournal);
78 + // Ignore errors from the following exclusion call.
79 + CSBackupSetItemExcluded(journal_url, TRUE, FALSE);
80 + CFRelease(journal_url);
81 + }
82 + CFRelease(database_url);
83 + }
84 +#endif
85 }
86
87
88 Index: ext/fts3/fts3_porter.c
89 ===================================================================
90 --- ext/fts3/fts3_porter.c (revision 86831)
91 +++ ext/fts3/fts3_porter.c (working copy)
92 @@ -129,7 +129,7 @@
93 /*
94 ** Vowel or consonant
95 */
96 -static const char cType[] = {
97 +static const char vOrCType[] = {
98 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,
99 1, 1, 1, 2, 1
100 };
101 @@ -153,7 +153,7 @@
102 char x = *z;
103 if( x==0 ) return 0;
104 assert( x>='a' && x<='z' );
105 - j = cType[x-'a'];
106 + j = vOrCType[x-'a'];
107 if( j<2 ) return j;
108 return z[1]==0 || isVowel(z + 1);
109 }
110 @@ -162,7 +162,7 @@
111 char x = *z;
112 if( x==0 ) return 0;
113 assert( x>='a' && x<='z' );
114 - j = cType[x-'a'];
115 + j = vOrCType[x-'a'];
116 if( j<2 ) return 1-j;
117 return isConsonant(z + 1);
118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698