644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
|
}
tarball_of_checkin(rid, &tarball, zName, pInclude, pExclude);
glob_free(pInclude);
glob_free(pExclude);
blob_write_to_file(&tarball, g.argv[3]);
blob_reset(&tarball);
}
/*
** WEBPAGE: tarball
** URL: /tarball
**
** Generate a compressed tarball for the check-in specified by the "r"
** query parameter. Return that compressed tarball as the HTTP reply
** content.
**
** Query parameters:
**
** name=NAME[.tar.gz] 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 compressed tarball.
** Defaults to "trunk". This query parameter used to
** be called "uuid" and "uuid" is still accepted for
** backwards compatibility. If omitted, the default
** check-in name is "trunk".
**
** 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 '..'.
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
|
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
|
}
tarball_of_checkin(rid, &tarball, zName, pInclude, pExclude);
glob_free(pInclude);
glob_free(pExclude);
blob_write_to_file(&tarball, g.argv[3]);
blob_reset(&tarball);
}
/*
** Check to see if the input string is of the form:
**
** checkin-name/filename.ext
**
** In other words, check to see if the input contains a single '/'
** character that separates a valid check-in name from a filename.
**
** If the condition is true, return the check-in name and set the
** input string to be the filename.
**
** If the condition is false, return NULL
*/
char *tar_uuid_from_name(char **pzName){
char *zName = *pzName;
int i, n;
for(i=n=0; zName[i]; i++){
if( zName[i]=='/' ){
if( n==0 ) n = i;
else return 0;
}
}
if( n==0 ) return 0;
if( zName[n+1]==0 ) return 0;
zName[n] = 0;
*pzName = fossil_strdup(&zName[n+1]);
return zName;
}
/*
** WEBPAGE: tarball
** URL: /tarball
**
** Generate a compressed tarball for the check-in specified by the "r"
** query parameter. Return that compressed tarball as the HTTP reply
** content.
**
** The r= and name= query parameters can be specified as extensions to the
** URI. Example, the following URIs are all equivalent:
**
** /tarball/release/xyz.tar.gz
** /tarball?r=release&name=xyz.tar.gz
** /tarball/xyz.tar.gz?r=release
** /tarball?name=release/xyz.tar.gz
**
** Query parameters:
**
** name=NAME[.tar.gz] 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 compressed tarball.
** Defaults to "trunk". This query parameter used to
** be called "uuid" and "uuid" is still accepted for
** backwards compatibility. If the name= query parameter
** contains one "/" character then the part before the /
** is the TAG and the part after the / is the true name.
** If no TAG is specified by any of the above means, then
** "trunk" is used as the default.
**
** 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 '..'.
|
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
|
Glob *pExclude = 0; /* The compiled ex= glob pattern */
Blob tarball; /* Tarball accumulated here */
const char *z;
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);
if( nName>7 && fossil_strcmp(&zName[nName-7], ".tar.gz")==0 ){
/* Special case: Remove the ".tar.gz" suffix. */
nName -= 7;
zName[nName] = 0;
}else{
/* If the file suffix is not ".tar.gz" then just remove the
** suffix up to and including the last "." */
|
|
<
>
>
|
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
|
Glob *pExclude = 0; /* The compiled ex= glob pattern */
Blob tarball; /* Tarball accumulated here */
const char *z;
login_check_credentials();
if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
load_control();
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";
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);
nName = strlen(zName);
if( nName>7 && fossil_strcmp(&zName[nName-7], ".tar.gz")==0 ){
/* Special case: Remove the ".tar.gz" suffix. */
nName -= 7;
zName[nName] = 0;
}else{
/* If the file suffix is not ".tar.gz" then just remove the
** suffix up to and including the last "." */
|