Fossil

Check-in [78d52675c5]
Login

Check-in [78d52675c5]

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

Overview
Comment:Show an error page when a managed file is not known at the requested check-in.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 78d52675c519a020066306ea0d4aa03916e92188040e3106a980b199d62607fc
User & Date: ashepilko 2020-05-10 03:12:05.568
Context
2020-05-10
04:50
File Browser: use wording 'file at check-in' to denote a file version snapshot and 'known file' to denote a name of a managed file. ... (check-in: 6fd34c5774 user: ashepilko tags: trunk)
03:12
Show an error page when a managed file is not known at the requested check-in. ... (check-in: 78d52675c5 user: ashepilko tags: trunk)
2020-05-09
21:10
Another 304 change: Omit only the Content-Type header. Retain the cache-control header lines. ... (check-in: fff9b6799c user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/info.c.
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155


2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171







2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188











2189
2190

2191
2192
2193
2194
2195
2196
2197
  if( zCI && strlen(zCI)==0 ){ zCI = 0; }
  if( zCI ){
    blob_zero(&dirname);
    hyperlinked_path(zName, &dirname, zCI, "dir", "");
    blob_reset(&dirname);

    if( name_to_uuid2(zCI, "ci", &zCIUuid) ){
      isSymbolicCI = (strncmp(zCIUuid, zCI, strlen(zCI)) != 0);
    }
  }
  if( isFile && zName ) {
    rid = artifact_from_ci_and_filename(0, "name");
  }else{
    rid = artifact_from_ci_and_filename(&url, 0);
  }
  if( rid==0 ){
    url_add_parameter(&url, "name", zName);
    if( isFile ){


      /* Do a top-level directory listing in /file mode if no argument
      ** specified */
      if( zName==0 || zName[0]==0 ){
        if( P("ci")==0 ) cgi_set_query_parameter("ci","tip");
        page_tree();
        return;
      }
      /* Look for a single file with the given name */
      rid = db_int(0,
         "SELECT fid FROM filename, mlink, event"
         " WHERE name=%Q"
         "   AND mlink.fnid=filename.fnid"
         "   AND event.objid=mlink.mid"
         " ORDER BY event.mtime DESC LIMIT 1",
         zName
      );







      /* If no file called NAME exists, instead look for a directory
      ** with that name, and do a directory listing */
      if( rid==0 ){
        int nName = (int)strlen(zName);
        if( nName && zName[nName-1]=='/' ) nName--;
        if( db_exists(
           "SELECT 1 FROM filename"
           " WHERE name GLOB '%.*q/*' AND substr(name,1,%d)=='%.*q/';",
           nName, zName, nName+1, nName, zName
        ) ){
          if( P("ci")==0 ) cgi_set_query_parameter("ci","tip");
          page_tree();
          return;
        }
      }
      /* If no file or directory called NAME: issue an error */
      if( rid==0 ){











        style_header("No such file");
        @ File '%h(zName)' does not exist in this repository.

        style_footer();
        return;
      }
    }else{
      rid = name_to_rid_www("name");
    }
  }







|










>
>
















>
>
>
>
>
>
>

















>
>
>
>
>
>
>
>
>
>
>
|
|
>







2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
  if( zCI && strlen(zCI)==0 ){ zCI = 0; }
  if( zCI ){
    blob_zero(&dirname);
    hyperlinked_path(zName, &dirname, zCI, "dir", "");
    blob_reset(&dirname);

    if( name_to_uuid2(zCI, "ci", &zCIUuid) ){
      isSymbolicCI = (sqlite3_strnicmp(zCIUuid, zCI, strlen(zCI)) != 0);
    }
  }
  if( isFile && zName ) {
    rid = artifact_from_ci_and_filename(0, "name");
  }else{
    rid = artifact_from_ci_and_filename(&url, 0);
  }
  if( rid==0 ){
    url_add_parameter(&url, "name", zName);
    if( isFile ){
      int isUnknownAtCI = 0;

      /* Do a top-level directory listing in /file mode if no argument
      ** specified */
      if( zName==0 || zName[0]==0 ){
        if( P("ci")==0 ) cgi_set_query_parameter("ci","tip");
        page_tree();
        return;
      }
      /* Look for a single file with the given name */
      rid = db_int(0,
         "SELECT fid FROM filename, mlink, event"
         " WHERE name=%Q"
         "   AND mlink.fnid=filename.fnid"
         "   AND event.objid=mlink.mid"
         " ORDER BY event.mtime DESC LIMIT 1",
         zName
      );
      /* If found only by the name, then the file is unknown in the check-in.
      ** Possibly, the file was renamed/deleted.
      */
      if( rid && zCIUuid ){
        rid = 0;
        isUnknownAtCI = 1;
      }
      /* If no file called NAME exists, instead look for a directory
      ** with that name, and do a directory listing */
      if( rid==0 ){
        int nName = (int)strlen(zName);
        if( nName && zName[nName-1]=='/' ) nName--;
        if( db_exists(
           "SELECT 1 FROM filename"
           " WHERE name GLOB '%.*q/*' AND substr(name,1,%d)=='%.*q/';",
           nName, zName, nName+1, nName, zName
        ) ){
          if( P("ci")==0 ) cgi_set_query_parameter("ci","tip");
          page_tree();
          return;
        }
      }
      /* If no file or directory called NAME: issue an error */
      if( rid==0 ){
        if( isUnknownAtCI ){
          if( isSymbolicCI ){
            zHeader = mprintf("No such file at %s", zCI);
          }else{
            zHeader = mprintf("No such file at [%S]", zCIUuid);
          }
          style_header("%s", zHeader);
          fossil_free(zHeader);
          @ File %z(href("%R/finfo?name=%T",zName))%h(zName)</a> does not exist
          @ in check-in [%z(href("/info/%!S",zCIUuid))%S(zCIUuid)</a>].
        }else{
          style_header("No such file");
          @ File '%h(zName)' does not exist in this repository.
        }
        style_footer();
        return;
      }
    }else{
      rid = name_to_rid_www("name");
    }
  }