Fossil

Check-in [89cf250dda]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:move "solution" closer to problem area, rather than too deeply abstracted in the machinery.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | clobber_fixer
Files: files | file ages | folders
SHA1: 89cf250dda1face9c867b7751deaebd7dde98a4a
User & Date: bch 2015-01-29 22:15:21.189
Context
2015-01-29
22:48
get to fossil_stat() via file_size(), and additionally protect 0-byte files in "clone" check-in: 45b060f08e user: bch tags: clobber_fixer
22:15
move "solution" closer to problem area, rather than too deeply abstracted in the machinery. check-in: 89cf250dda user: bch tags: clobber_fixer
20:21
proposed fix for clobbering existing files [5ba427be8809342c6fbdcf48c9c8365467048d28] check-in: bb15d408a4 user: bch tags: clobber_fixer
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/db.c.
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
/*
** Open a database file.  Return a pointer to the new database
** connection.  An error results in process abort.
*/
LOCAL sqlite3 *db_open(const char *zDbName){
  int rc;
  sqlite3 *db;
  struct stat sb;

  if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName);

  if (0 == stat(zDbName, &sb)) {
       db_err("[%s]: %s", zDbName, "File already exists.");
  }

  rc = sqlite3_open_v2(
       zDbName, &db,
       SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
       g.zVfsName
  );
  if( rc!=SQLITE_OK ){
    db_err("[%s]: %s", zDbName, sqlite3_errmsg(db));







<



<
<
<
<







815
816
817
818
819
820
821

822
823
824




825
826
827
828
829
830
831
/*
** Open a database file.  Return a pointer to the new database
** connection.  An error results in process abort.
*/
LOCAL sqlite3 *db_open(const char *zDbName){
  int rc;
  sqlite3 *db;


  if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName);





  rc = sqlite3_open_v2(
       zDbName, &db,
       SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
       g.zVfsName
  );
  if( rc!=SQLITE_OK ){
    db_err("[%s]: %s", zDbName, sqlite3_errmsg(db));
1673
1674
1675
1676
1677
1678
1679

1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692





1693
1694
1695
1696
1697
1698
1699
*/
void create_repository_cmd(void){
  char *zPassword;
  const char *zTemplate;      /* Repository from which to copy settings */
  const char *zDate;          /* Date of the initial check-in */
  const char *zDefaultUser;   /* Optional name of the default user */
  int makeServerCodes;


  zTemplate = find_option("template",0,1);
  zDate = find_option("date-override",0,1);
  zDefaultUser = find_option("admin-user","A",1);
  makeServerCodes = find_option("docker", 0, 0)==0;

  find_option("empty", 0, 0); /* deprecated */
  /* We should be done with options.. */
  verify_all_options();

  if( g.argc!=3 ){
    usage("REPOSITORY-NAME");
  }





  db_create_repository(g.argv[2]);
  db_open_repository(g.argv[2]);
  db_open_config(0);
  if( zTemplate ) db_attach(zTemplate, "settingSrc");
  db_begin_transaction();
  db_initial_setup(zTemplate, zDate, zDefaultUser, makeServerCodes);
  db_end_transaction(0);







>













>
>
>
>
>







1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
*/
void create_repository_cmd(void){
  char *zPassword;
  const char *zTemplate;      /* Repository from which to copy settings */
  const char *zDate;          /* Date of the initial check-in */
  const char *zDefaultUser;   /* Optional name of the default user */
  int makeServerCodes;
  struct stat sb;

  zTemplate = find_option("template",0,1);
  zDate = find_option("date-override",0,1);
  zDefaultUser = find_option("admin-user","A",1);
  makeServerCodes = find_option("docker", 0, 0)==0;

  find_option("empty", 0, 0); /* deprecated */
  /* We should be done with options.. */
  verify_all_options();

  if( g.argc!=3 ){
    usage("REPOSITORY-NAME");
  }
 
  if (0 == stat(g.argv[2], &sb)) {
       fossil_fatal("[%s]: %s", g.argv[2], "File already exists.");
  }

  db_create_repository(g.argv[2]);
  db_open_repository(g.argv[2]);
  db_open_config(0);
  if( zTemplate ) db_attach(zTemplate, "settingSrc");
  db_begin_transaction();
  db_initial_setup(zTemplate, zDate, zDefaultUser, makeServerCodes);
  db_end_transaction(0);