Fossil

Check-in [69145d9d]
Login

Check-in [69145d9d]

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

Overview
Comment:Calling db_open() to determine if a given repository is valid rather than a hand-rolled sqlite3_open() call. This then allows us to call db_looks_like_a_repository() to determine if the DB is a valid repo rather than duplicate the checks it already has in another nearby context. This is part of the apndvfs vs normal-case stuff done in prior commits, consolidating the notion of "valid" to a single spot in the code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 69145d9d992f12e713316cf8a17692985b7916dc2c9e51751c7826b9056111d7
User & Date: wyoung 2022-02-28 23:32:09
Context
2022-03-01
17:21
Allow optional "-" characters in the huge string argument to bid= on /timeline so that when the hyperlink will have wrap opportunities when pasted into the chat. ... (check-in: adfc1a6b user: drh tags: trunk)
2022-02-28
23:32
Calling db_open() to determine if a given repository is valid rather than a hand-rolled sqlite3_open() call. This then allows us to call db_looks_like_a_repository() to determine if the DB is a valid repo rather than duplicate the checks it already has in another nearby context. This is part of the apndvfs vs normal-case stuff done in prior commits, consolidating the notion of "valid" to a single spot in the code. ... (check-in: 69145d9d user: wyoung tags: trunk)
20:49
Since checkin [d8c32ebdff], file_fullexename() function is supported windows, remove comment saying otherwize. (no code change) ... (check-in: 491b986d user: mgagnon tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/db.c.

2138
2139
2140
2141
2142
2143
2144

2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
  i64 sz;
  int rc;
  int res = 0;
  sqlite3_stmt *pStmt = 0;

  sz = file_size(zDbName, ExtFILE);
  if( sz<16834 ) return 0;

  if( sz%512 ) return 0;
  rc = sqlite3_open(zDbName, &db);
  if( rc ) goto is_repo_end;
  rc = sqlite3_prepare_v2(db, 
       "SELECT count(*) FROM sqlite_schema"
       " WHERE name COLLATE nocase IN"
       "('blob','delta','rcvfrom','user','config','mlink','plink');",
       -1, &pStmt, 0);
  if( rc ) goto is_repo_end;
  rc = sqlite3_step(pStmt);







>
|
<
|







2138
2139
2140
2141
2142
2143
2144
2145
2146

2147
2148
2149
2150
2151
2152
2153
2154
  i64 sz;
  int rc;
  int res = 0;
  sqlite3_stmt *pStmt = 0;

  sz = file_size(zDbName, ExtFILE);
  if( sz<16834 ) return 0;
  db = db_open(zDbName);
  if( !db ) return 0;

  if( !g.zVfsName && sz%512 ) return 0;
  rc = sqlite3_prepare_v2(db, 
       "SELECT count(*) FROM sqlite_schema"
       " WHERE name COLLATE nocase IN"
       "('blob','delta','rcvfrom','user','config','mlink','plink');",
       -1, &pStmt, 0);
  if( rc ) goto is_repo_end;
  rc = sqlite3_step(pStmt);
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
    if( g.localOpen ){
      zDbName = db_repository_filename();
    }
    if( zDbName==0 ){
      db_err("unable to find the name of a repository database");
    }
  }
  /* Don't change the file size test to call db_looks_like_a_repository()
   * or copy code from it. The sz%512 bit in particular is wrong for the
   * apndvfs case in db_open() above. */
  if( file_access(zDbName, R_OK) || file_size(zDbName, ExtFILE)<1024 ){
    if( file_access(zDbName, F_OK) ){
#ifdef FOSSIL_ENABLE_JSON
      g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
#endif
      fossil_fatal("repository does not exist or"
                   " is in an unreadable directory: %s", zDbName);
    }else if( file_access(zDbName, R_OK) ){







|
<
<
<







2186
2187
2188
2189
2190
2191
2192
2193



2194
2195
2196
2197
2198
2199
2200
    if( g.localOpen ){
      zDbName = db_repository_filename();
    }
    if( zDbName==0 ){
      db_err("unable to find the name of a repository database");
    }
  }
  if( !db_looks_like_a_repository(zDbName) ){



    if( file_access(zDbName, F_OK) ){
#ifdef FOSSIL_ENABLE_JSON
      g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
#endif
      fossil_fatal("repository does not exist or"
                   " is in an unreadable directory: %s", zDbName);
    }else if( file_access(zDbName, R_OK) ){