Fossil SCM
Avoid attaching a database file that already exists.
Commit
052c5f24a96937d8eca392bb0fa5e6657b739fd8917624ded03a7fcc2c055110
Parent
3a8abf492ab21ab…
1 file changed
+1
M
src/db.c
+1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1257,10 +1257,11 @@ | ||
| 1257 | 1257 | ** zDbName is the name of a database file. Attach zDbName using |
| 1258 | 1258 | ** the name zLabel. |
| 1259 | 1259 | */ |
| 1260 | 1260 | void db_attach(const char *zDbName, const char *zLabel){ |
| 1261 | 1261 | Blob key; |
| 1262 | + if( db_table_exists(zLabel,"sqlite_master") ) return; | |
| 1262 | 1263 | blob_init(&key, 0, 0); |
| 1263 | 1264 | db_maybe_obtain_encryption_key(zDbName, &key); |
| 1264 | 1265 | if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){ |
| 1265 | 1266 | char *zCmd = sqlite3_mprintf("ATTACH DATABASE %Q AS %Q KEY %Q", |
| 1266 | 1267 | zDbName, zLabel, blob_str(&key)); |
| 1267 | 1268 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1257,10 +1257,11 @@ | |
| 1257 | ** zDbName is the name of a database file. Attach zDbName using |
| 1258 | ** the name zLabel. |
| 1259 | */ |
| 1260 | void db_attach(const char *zDbName, const char *zLabel){ |
| 1261 | Blob key; |
| 1262 | blob_init(&key, 0, 0); |
| 1263 | db_maybe_obtain_encryption_key(zDbName, &key); |
| 1264 | if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){ |
| 1265 | char *zCmd = sqlite3_mprintf("ATTACH DATABASE %Q AS %Q KEY %Q", |
| 1266 | zDbName, zLabel, blob_str(&key)); |
| 1267 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1257,10 +1257,11 @@ | |
| 1257 | ** zDbName is the name of a database file. Attach zDbName using |
| 1258 | ** the name zLabel. |
| 1259 | */ |
| 1260 | void db_attach(const char *zDbName, const char *zLabel){ |
| 1261 | Blob key; |
| 1262 | if( db_table_exists(zLabel,"sqlite_master") ) return; |
| 1263 | blob_init(&key, 0, 0); |
| 1264 | db_maybe_obtain_encryption_key(zDbName, &key); |
| 1265 | if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){ |
| 1266 | char *zCmd = sqlite3_mprintf("ATTACH DATABASE %Q AS %Q KEY %Q", |
| 1267 | zDbName, zLabel, blob_str(&key)); |
| 1268 |