951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
|
** /zip/[VERSION/]NAME.zip
** /sqlar/[VERSION/]NAME.sqlar
**
** Generate a ZIP Archive or an SQL Archive for the check-in specified by
** VERSION. The archive is called NAME.zip or NAME.sqlar and has a top-level
** directory called NAME.
**
** The optional VERSION element defaults to "trunk" per the r= rules below.
** All of the following URLs are equivalent:
**
** /zip/release/xyz.zip
** /zip?r=release&name=xyz.zip
** /zip/xyz.zip?r=release
** /zip?name=release/xyz.zip
**
** Query parameters:
**
** name=[CKIN/]NAME The optional CKIN component of the name= parameter
** identifies the check-in from which the archive is
** constructed. If CKIN is omitted and there is no
** r= query parameter, then use "trunk". NAME is the
** name of the download file. The top-level directory
** in the generated archive is called by NAME with the
** file extension removed.
**
** r=TAG TAG identifies the check-in that is turned into an
** SQL or ZIP archive. The default value is "trunk".
** If r= is omitted and if the name= query parameter
** contains one "/" character then the of part the
** name= value before the / becomes the TAG and the
** part of the name= value after the / is the download
** filename. If no check-in is specified by either
** name= or r=, then "trunk" is used.
**
** in=PATTERN Only include files that match the comma-separate
** list of GLOB patterns in PATTERN, as with ex=
**
** ex=PATTERN Omit any file that match PATTERN. PATTERN is a
** comma-separated list of GLOB patterns, where each
** pattern can optionally be quoted using ".." or '..'.
|
|
>
|
>
|
>
|
>
|
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
|
** /zip/[VERSION/]NAME.zip
** /sqlar/[VERSION/]NAME.sqlar
**
** Generate a ZIP Archive or an SQL Archive for the check-in specified by
** VERSION. The archive is called NAME.zip or NAME.sqlar and has a top-level
** directory called NAME.
**
** The optional VERSION element defaults to the name of the main branch
** (usually "trunk") per the r= rules below.
** All of the following URLs are equivalent:
**
** /zip/release/xyz.zip
** /zip?r=release&name=xyz.zip
** /zip/xyz.zip?r=release
** /zip?name=release/xyz.zip
**
** Query parameters:
**
** name=[CKIN/]NAME The optional CKIN component of the name= parameter
** identifies the check-in from which the archive is
** constructed. If CKIN is omitted and there is no
** r= query parameter, then use the name of the main
** branch (usually "trunk"). NAME is the
** name of the download file. The top-level directory
** in the generated archive is called by NAME with the
** file extension removed.
**
** r=TAG TAG identifies the check-in that is turned into an
** SQL or ZIP archive. The default value is the name
** of the main branch (usually "trunk").
** If r= is omitted and if the name= query parameter
** contains one "/" character then the of part the
** name= value before the / becomes the TAG and the
** part of the name= value after the / is the download
** filename. If no check-in is specified by either
** name= or r=, then the name of the main branch
** (usually "trunk") is used.
**
** in=PATTERN Only include files that match the comma-separate
** list of GLOB patterns in PATTERN, as with ex=
**
** ex=PATTERN Omit any file that match PATTERN. PATTERN is a
** comma-separated list of GLOB patterns, where each
** pattern can optionally be quoted using ".." or '..'.
|
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
|
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( robot_restrict("zip") ) return;
if( fossil_strcmp(g.zPath, "sqlar")==0 ){
eType = ARCHIVE_SQLAR;
zType = "SQL";
}else{
eType = ARCHIVE_ZIP;
zType = "ZIP";
}
fossil_nice_default();
zName = fossil_strdup(PD("name",""));
z = P("r");
if( z==0 ) z = P("uuid");
if( z==0 ) z = tar_uuid_from_name(&zName);
if( z==0 ) z = "trunk";
nName = strlen(zName);
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);
|
>
|
|
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
|
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 */
char *zMainBranch = db_get("main-branch", 0);
login_check_credentials();
if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
if( robot_restrict("zip") ) return;
if( fossil_strcmp(g.zPath, "sqlar")==0 ){
eType = ARCHIVE_SQLAR;
zType = "SQL";
}else{
eType = ARCHIVE_ZIP;
zType = "ZIP";
}
fossil_nice_default();
zName = fossil_strdup(PD("name",""));
z = P("r");
if( z==0 ) z = P("uuid");
if( z==0 ) z = tar_uuid_from_name(&zName);
if( z==0 ) z = fossil_strdup(zMainBranch);
nName = strlen(zName);
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);
|
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
|
blob_zero(&zip);
if( cache_read(&zip, zKey)==0 ){
zip_of_checkin(eType, rid, &zip, zName, pInclude, pExclude, 0);
cache_write(&zip, zKey);
}
glob_free(pInclude);
glob_free(pExclude);
fossil_free(zName);
fossil_free(zRid);
g.zOpenRevision = 0;
blob_reset(&cacheKey);
cgi_set_content(&zip);
if( eType==ARCHIVE_ZIP ){
cgi_set_content_type("application/zip");
}else{
cgi_set_content_type("application/sqlar");
}
}
|
>
|
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
|
blob_zero(&zip);
if( cache_read(&zip, zKey)==0 ){
zip_of_checkin(eType, rid, &zip, zName, pInclude, pExclude, 0);
cache_write(&zip, zKey);
}
glob_free(pInclude);
glob_free(pExclude);
fossil_free(zMainBranch);
fossil_free(zName);
fossil_free(zRid);
g.zOpenRevision = 0;
blob_reset(&cacheKey);
cgi_set_content(&zip);
if( eType==ARCHIVE_ZIP ){
cgi_set_content_type("application/zip");
}else{
cgi_set_content_type("application/sqlar");
}
}
|