Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the /sqlar webpage. Link to this page from the /info page. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
768e19219f86937b0b8af32896397981 |
| User & Date: | drh 2017-12-04 21:29:53.780 |
Context
|
2017-12-04
| ||
| 21:49 | Make the default page size on SQL archives 512 bytes. ... (check-in: f5c81a6c4f user: drh tags: trunk) | |
| 21:29 | Add the /sqlar webpage. Link to this page from the /info page. ... (check-in: 768e19219f user: drh tags: trunk) | |
| 20:39 | Add the "fossil sqlar" command. Like "fossil zip", except generates sqlar archives. ... (check-in: 7eb5b0a2ae user: dan tags: trunk) | |
Changes
Changes to src/info.c.
| ︙ | ︙ | |||
754 755 756 757 758 759 760 |
/* The Download: line */
if( g.anon.Zip ){
char *zUrl = mprintf("%R/tarball/%t-%S.tar.gz?uuid=%s",
zPJ, zUuid, zUuid);
@ </td></tr>
@ <tr><th>Downloads:</th><td>
@ %z(href("%s",zUrl))Tarball</a>
| | | | 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 |
/* The Download: line */
if( g.anon.Zip ){
char *zUrl = mprintf("%R/tarball/%t-%S.tar.gz?uuid=%s",
zPJ, zUuid, zUuid);
@ </td></tr>
@ <tr><th>Downloads:</th><td>
@ %z(href("%s",zUrl))Tarball</a>
@ | %z(href("%R/zip/%t-%S.zip?uuid=%!S",zPJ,zUuid,zUuid))ZIP archive</a>
@ | %z(href("%R/sqlar/%t-%S.sqlar?uuid=%!S",zPJ,zUuid,zUuid))SQL archive</a>
fossil_free(zUrl);
}
@ </td></tr>
@ <tr><th>Other Links:</th>
@ <td>
@ %z(href("%R/tree?ci=%!S",zUuid))files</a>
@ | %z(href("%R/fileage?name=%!S",zUuid))file ages</a>
|
| ︙ | ︙ |
Changes to src/zip.c.
| ︙ | ︙ | |||
823 824 825 826 827 828 829 |
** -R REPOSITORY Specify a Fossil repository
*/
void sqlar_cmd(void){
archive_cmd(ARCHIVE_SQLAR);
}
/*
| | | | | | | 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 |
** -R REPOSITORY Specify a Fossil repository
*/
void sqlar_cmd(void){
archive_cmd(ARCHIVE_SQLAR);
}
/*
** WEBPAGE: sqlar
** WEBPAGE: zip
**
** Generate a ZIP or SQL archive for the check-in specified by the "r"
** query parameter. Return the archive as the HTTP reply content.
**
** Query parameters:
**
** name=NAME The base name of the output file. The default
** value is a configuration parameter in the project
** settings. A prefix of the name, omitting the
** extension, is used as the top-most directory name.
**
** r=TAG The check-in that is turned into a ZIP archive.
** Defaults to "trunk". This query parameter used to
** be called "uuid" and the older "uuid" name is still
|
| ︙ | ︙ | |||
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 |
int nName, nRid;
const char *zInclude; /* The in= query parameter */
const char *zExclude; /* The ex= query parameter */
Blob cacheKey; /* The key to cache */
Glob *pInclude = 0; /* The compiled in= glob pattern */
Glob *pExclude = 0; /* The compiled ex= glob pattern */
Blob zip; /* ZIP archive accumulated here */
login_check_credentials();
if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
load_control();
zName = mprintf("%s", PD("name",""));
nName = strlen(zName);
z = P("r");
if( z==0 ) z = P("uuid");
if( z==0 ) z = "trunk";
g.zOpenRevision = zRid = fossil_strdup(z);
nRid = strlen(zRid);
zInclude = P("in");
if( zInclude ) pInclude = glob_create(zInclude);
zExclude = P("ex");
if( zExclude ) pExclude = glob_create(zExclude);
| > > > > > > > > > > > | > > > > > > > > | | | | | | | | > | > > | > | 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 |
int nName, nRid;
const char *zInclude; /* The in= query parameter */
const char *zExclude; /* The ex= query parameter */
Blob cacheKey; /* The key to cache */
Glob *pInclude = 0; /* The compiled in= glob pattern */
Glob *pExclude = 0; /* The compiled ex= glob pattern */
Blob zip; /* ZIP archive accumulated here */
int eType = ARCHIVE_ZIP; /* Type of archive to generate */
char *zType; /* Human-readable archive type */
login_check_credentials();
if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
if( fossil_strcmp(g.zPath, "sqlar")==0 ){
eType = ARCHIVE_SQLAR;
zType = "SQL";
}else{
eType = ARCHIVE_ZIP;
zType = "ZIP";
}
load_control();
zName = mprintf("%s", PD("name",""));
nName = strlen(zName);
z = P("r");
if( z==0 ) z = P("uuid");
if( z==0 ) z = "trunk";
g.zOpenRevision = zRid = fossil_strdup(z);
nRid = strlen(zRid);
zInclude = P("in");
if( zInclude ) pInclude = glob_create(zInclude);
zExclude = P("ex");
if( zExclude ) pExclude = glob_create(zExclude);
if( eType==ARCHIVE_ZIP
&& nName>4
&& fossil_strcmp(&zName[nName-4], ".zip")==0
){
/* Special case: Remove the ".zip" suffix. */
nName -= 4;
zName[nName] = 0;
}else if( eType==ARCHIVE_SQLAR
&& nName>6
&& fossil_strcmp(&zName[nName-6], ".sqlar")==0
){
/* Special case: Remove the ".sqlar" suffix. */
nName -= 6;
zName[nName] = 0;
}else{
/* If the file suffix is not ".zip" or ".sqlar" then just remove the
** suffix up to and including the last "." */
for(nName=strlen(zName)-1; nName>5; nName--){
if( zName[nName]=='.' ){
zName[nName] = 0;
break;
}
}
}
rid = symbolic_name_to_rid(nRid?zRid:zName, "ci");
if( rid<=0 ){
cgi_set_status(404, "Not Found");
@ Not found
return;
}
if( nRid==0 && nName>10 ) zName[10] = 0;
/* Compute a unique key for the cache entry based on query parameters */
blob_init(&cacheKey, 0, 0);
blob_appendf(&cacheKey, "/%s/%z", g.zPath, rid_to_uuid(rid));
blob_appendf(&cacheKey, "/%q", zName);
if( zInclude ) blob_appendf(&cacheKey, ",in=%Q", zInclude);
if( zExclude ) blob_appendf(&cacheKey, ",ex=%Q", zExclude);
zKey = blob_str(&cacheKey);
if( P("debug")!=0 ){
style_header("%s Archive Generator Debug Screen", zType);
@ zName = "%h(zName)"<br />
@ rid = %d(rid)<br />
if( zInclude ){
@ zInclude = "%h(zInclude)"<br />
}
if( zExclude ){
@ zExclude = "%h(zExclude)"<br />
}
@ zKey = "%h(zKey)"
style_footer();
return;
}
if( referred_from_login() ){
style_header("%s Archive Download", zType);
@ <form action='%R/%s(g.zPath)/%h(zName).%s(g.zPath)'>
cgi_query_parameters_to_hidden();
@ <p>%s(zType) Archive named <b>%h(zName).%s(g.zPath)</b>
@ holding the content of check-in <b>%h(zRid)</b>:
@ <input type="submit" value="Download" />
@ </form>
style_footer();
return;
}
blob_zero(&zip);
if( cache_read(&zip, zKey)==0 ){
zip_of_checkin(eType, rid, &zip, zName, pInclude, pExclude);
cache_write(&zip, zKey);
}
glob_free(pInclude);
glob_free(pExclude);
fossil_free(zName);
fossil_free(zRid);
blob_reset(&cacheKey);
cgi_set_content(&zip);
if( eType==ARCHIVE_ZIP ){
cgi_set_content_type("application/zip");
}else{
cgi_set_content_type("application/sqlar");
}
}
|