зеркало из https://github.com/mozilla/gecko-dev.git
Fix DB opening code so that, if O_CREATE is set, so is O_TRUNC.
This commit is contained in:
Родитель
4197d0708e
Коммит
efaa8ff8e7
|
@ -120,9 +120,11 @@ readInBookmarksOnInit(RDFFile f)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
PR_Close(fp);
|
PR_Close(fp);
|
||||||
freeMem(f->line);
|
#if 0
|
||||||
freeMem(f->currentSlot);
|
if (f->line != NULL) freeMem(f->line);
|
||||||
freeMem(f->holdOver);
|
if (f->currentSlot != NULL) freeMem(f->currentSlot);
|
||||||
|
if (f->holdOver != NULL) freeMem(f->holdOver);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,6 +135,8 @@ DBM_OpenDBMStore (DBMRDF store, char* directory)
|
||||||
PRBool createp = 0;
|
PRBool createp = 0;
|
||||||
char* dbPathname;
|
char* dbPathname;
|
||||||
char* dirPathname;
|
char* dirPathname;
|
||||||
|
int mode=(O_RDWR | O_CREAT);
|
||||||
|
|
||||||
CHECK_VAR1(profileDirURL);
|
CHECK_VAR1(profileDirURL);
|
||||||
dirPathname = makeDBURL(directory);
|
dirPathname = makeDBURL(directory);
|
||||||
CallPRMkDirUsingFileURL(dirPathname, 00700);
|
CallPRMkDirUsingFileURL(dirPathname, 00700);
|
||||||
|
@ -140,10 +144,13 @@ DBM_OpenDBMStore (DBMRDF store, char* directory)
|
||||||
|
|
||||||
dbPathname = makeRDFDBURL(directory, "names.db");
|
dbPathname = makeRDFDBURL(directory, "names.db");
|
||||||
CHECK_VAR1(dbPathname);
|
CHECK_VAR1(dbPathname);
|
||||||
store->nameDB = CallDBOpenUsingFileURL(dbPathname, O_RDWR, 0644, DB_HASH, &hash_info);
|
store->nameDB = CallDBOpenUsingFileURL(dbPathname,
|
||||||
|
O_RDWR, 0644, DB_HASH, &hash_info);
|
||||||
if (store->nameDB == NULL) {
|
if (store->nameDB == NULL) {
|
||||||
createp = 1;
|
createp = 1;
|
||||||
store->nameDB = CallDBOpenUsingFileURL(dbPathname, O_RDWR | O_CREAT, 0644, DB_HASH, &hash_info);
|
mode = (O_RDWR | O_CREAT | O_TRUNC);
|
||||||
|
store->nameDB = CallDBOpenUsingFileURL(dbPathname,
|
||||||
|
mode, 0644, DB_HASH, &hash_info);
|
||||||
}
|
}
|
||||||
freeMem(dbPathname);
|
freeMem(dbPathname);
|
||||||
CHECK_VAR1(store->nameDB);
|
CHECK_VAR1(store->nameDB);
|
||||||
|
@ -151,14 +158,14 @@ DBM_OpenDBMStore (DBMRDF store, char* directory)
|
||||||
CHECK_VAR1(dbPathname);
|
CHECK_VAR1(dbPathname);
|
||||||
hash_info.bsize = 2056;
|
hash_info.bsize = 2056;
|
||||||
store->childrenDB = CallDBOpenUsingFileURL(dbPathname,
|
store->childrenDB = CallDBOpenUsingFileURL(dbPathname,
|
||||||
O_RDWR | O_CREAT, 0644, DB_HASH, &hash_info);
|
mode, 0644, DB_HASH, &hash_info);
|
||||||
freeMem(dbPathname);
|
freeMem(dbPathname);
|
||||||
CHECK_VAR1(store->childrenDB);
|
CHECK_VAR1(store->childrenDB);
|
||||||
|
|
||||||
dbPathname = makeRDFDBURL(directory, "lstr.db");
|
dbPathname = makeRDFDBURL(directory, "lstr.db");
|
||||||
hash_info.bsize = 1024 ;
|
hash_info.bsize = 1024 ;
|
||||||
store->propDB = CallDBOpenUsingFileURL(dbPathname,
|
store->propDB = CallDBOpenUsingFileURL(dbPathname,
|
||||||
O_RDWR | O_CREAT, 0644, DB_HASH, &hash_info);
|
mode, 0644, DB_HASH, &hash_info);
|
||||||
freeMem(dbPathname);
|
freeMem(dbPathname);
|
||||||
CHECK_VAR1(store->propDB);
|
CHECK_VAR1(store->propDB);
|
||||||
|
|
||||||
|
@ -166,15 +173,13 @@ DBM_OpenDBMStore (DBMRDF store, char* directory)
|
||||||
CHECK_VAR1(dbPathname);
|
CHECK_VAR1(dbPathname);
|
||||||
hash_info.bsize = 1024*16;
|
hash_info.bsize = 1024*16;
|
||||||
store->invPropDB = CallDBOpenUsingFileURL(dbPathname,
|
store->invPropDB = CallDBOpenUsingFileURL(dbPathname,
|
||||||
O_RDWR | O_CREAT, 0644, DB_HASH, &hash_info);
|
mode, 0644, DB_HASH, &hash_info);
|
||||||
freeMem(dbPathname);
|
freeMem(dbPathname);
|
||||||
CHECK_VAR1(store->invPropDB);
|
CHECK_VAR1(store->invPropDB);
|
||||||
|
|
||||||
if (strcmp(directory, "NavCen") == 0) {
|
if (strcmp(directory, "NavCen") == 0) {
|
||||||
RDF_Resource bmk = RDF_GetResource(NULL, "NC:Bookmarks", true);
|
RDF_Resource bmk = RDF_GetResource(NULL, "NC:Bookmarks", true);
|
||||||
if (createp) {
|
if (createp) {
|
||||||
PRBool nlocalStoreAssert1 (RDFFile f, RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv) ;
|
|
||||||
RDFFile newFile;
|
RDFFile newFile;
|
||||||
doingFirstTimeInitp = 1;
|
doingFirstTimeInitp = 1;
|
||||||
newFile = makeRDFFile(gBookmarkURL, bmk, true);
|
newFile = makeRDFFile(gBookmarkURL, bmk, true);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче