Fossil SCM
move "solution" closer to problem area, rather than too deeply abstracted in the machinery.
Commit
89cf250dda1face9c867b7751deaebd7dde98a4a
Parent
bb15d408a4d68f8…
1 file changed
+6
-5
M
src/db.c
+6
-5
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -817,18 +817,13 @@ | ||
| 817 | 817 | ** connection. An error results in process abort. |
| 818 | 818 | */ |
| 819 | 819 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 820 | 820 | int rc; |
| 821 | 821 | sqlite3 *db; |
| 822 | - struct stat sb; | |
| 823 | 822 | |
| 824 | 823 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 825 | 824 | |
| 826 | - if (0 == stat(zDbName, &sb)) { | |
| 827 | - db_err("[%s]: %s", zDbName, "File already exists."); | |
| 828 | - } | |
| 829 | - | |
| 830 | 825 | rc = sqlite3_open_v2( |
| 831 | 826 | zDbName, &db, |
| 832 | 827 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 833 | 828 | g.zVfsName |
| 834 | 829 | ); |
| @@ -1675,10 +1670,11 @@ | ||
| 1675 | 1670 | char *zPassword; |
| 1676 | 1671 | const char *zTemplate; /* Repository from which to copy settings */ |
| 1677 | 1672 | const char *zDate; /* Date of the initial check-in */ |
| 1678 | 1673 | const char *zDefaultUser; /* Optional name of the default user */ |
| 1679 | 1674 | int makeServerCodes; |
| 1675 | + struct stat sb; | |
| 1680 | 1676 | |
| 1681 | 1677 | zTemplate = find_option("template",0,1); |
| 1682 | 1678 | zDate = find_option("date-override",0,1); |
| 1683 | 1679 | zDefaultUser = find_option("admin-user","A",1); |
| 1684 | 1680 | makeServerCodes = find_option("docker", 0, 0)==0; |
| @@ -1688,10 +1684,15 @@ | ||
| 1688 | 1684 | verify_all_options(); |
| 1689 | 1685 | |
| 1690 | 1686 | if( g.argc!=3 ){ |
| 1691 | 1687 | usage("REPOSITORY-NAME"); |
| 1692 | 1688 | } |
| 1689 | + | |
| 1690 | + if (0 == stat(g.argv[2], &sb)) { | |
| 1691 | + fossil_fatal("[%s]: %s", g.argv[2], "File already exists."); | |
| 1692 | + } | |
| 1693 | + | |
| 1693 | 1694 | db_create_repository(g.argv[2]); |
| 1694 | 1695 | db_open_repository(g.argv[2]); |
| 1695 | 1696 | db_open_config(0); |
| 1696 | 1697 | if( zTemplate ) db_attach(zTemplate, "settingSrc"); |
| 1697 | 1698 | db_begin_transaction(); |
| 1698 | 1699 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -817,18 +817,13 @@ | |
| 817 | ** connection. An error results in process abort. |
| 818 | */ |
| 819 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 820 | int rc; |
| 821 | sqlite3 *db; |
| 822 | struct stat sb; |
| 823 | |
| 824 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 825 | |
| 826 | if (0 == stat(zDbName, &sb)) { |
| 827 | db_err("[%s]: %s", zDbName, "File already exists."); |
| 828 | } |
| 829 | |
| 830 | rc = sqlite3_open_v2( |
| 831 | zDbName, &db, |
| 832 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 833 | g.zVfsName |
| 834 | ); |
| @@ -1675,10 +1670,11 @@ | |
| 1675 | char *zPassword; |
| 1676 | const char *zTemplate; /* Repository from which to copy settings */ |
| 1677 | const char *zDate; /* Date of the initial check-in */ |
| 1678 | const char *zDefaultUser; /* Optional name of the default user */ |
| 1679 | int makeServerCodes; |
| 1680 | |
| 1681 | zTemplate = find_option("template",0,1); |
| 1682 | zDate = find_option("date-override",0,1); |
| 1683 | zDefaultUser = find_option("admin-user","A",1); |
| 1684 | makeServerCodes = find_option("docker", 0, 0)==0; |
| @@ -1688,10 +1684,15 @@ | |
| 1688 | verify_all_options(); |
| 1689 | |
| 1690 | if( g.argc!=3 ){ |
| 1691 | usage("REPOSITORY-NAME"); |
| 1692 | } |
| 1693 | db_create_repository(g.argv[2]); |
| 1694 | db_open_repository(g.argv[2]); |
| 1695 | db_open_config(0); |
| 1696 | if( zTemplate ) db_attach(zTemplate, "settingSrc"); |
| 1697 | db_begin_transaction(); |
| 1698 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -817,18 +817,13 @@ | |
| 817 | ** connection. An error results in process abort. |
| 818 | */ |
| 819 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 820 | int rc; |
| 821 | sqlite3 *db; |
| 822 | |
| 823 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 824 | |
| 825 | rc = sqlite3_open_v2( |
| 826 | zDbName, &db, |
| 827 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 828 | g.zVfsName |
| 829 | ); |
| @@ -1675,10 +1670,11 @@ | |
| 1670 | char *zPassword; |
| 1671 | const char *zTemplate; /* Repository from which to copy settings */ |
| 1672 | const char *zDate; /* Date of the initial check-in */ |
| 1673 | const char *zDefaultUser; /* Optional name of the default user */ |
| 1674 | int makeServerCodes; |
| 1675 | struct stat sb; |
| 1676 | |
| 1677 | zTemplate = find_option("template",0,1); |
| 1678 | zDate = find_option("date-override",0,1); |
| 1679 | zDefaultUser = find_option("admin-user","A",1); |
| 1680 | makeServerCodes = find_option("docker", 0, 0)==0; |
| @@ -1688,10 +1684,15 @@ | |
| 1684 | verify_all_options(); |
| 1685 | |
| 1686 | if( g.argc!=3 ){ |
| 1687 | usage("REPOSITORY-NAME"); |
| 1688 | } |
| 1689 | |
| 1690 | if (0 == stat(g.argv[2], &sb)) { |
| 1691 | fossil_fatal("[%s]: %s", g.argv[2], "File already exists."); |
| 1692 | } |
| 1693 | |
| 1694 | db_create_repository(g.argv[2]); |
| 1695 | db_open_repository(g.argv[2]); |
| 1696 | db_open_config(0); |
| 1697 | if( zTemplate ) db_attach(zTemplate, "settingSrc"); |
| 1698 | db_begin_transaction(); |
| 1699 |