PreviewSubmit: always allow tgz format
Currently the setting archive.download is used in two different cases: * It is used to specify formats for downloading a patch set archive * It is used to specify the formats in preview_submit However these two use cases serve different purposes: The format for downloading a patch set archive can be used to adapt to the resource environment: * When bandwidth is cheap, tar is a good choice. * When CPU is available, tbz2 and txz are good candidates. * tgz does an ok job w.r.t. any resource. * the admin may deem downloading patches as an archive is not a good idea and disable it completely by allowing no formats. The format for preview_submit is different, though, because it is used as a wrapper around already compressed files (git bundles), so it makes no sense to spent a lot of CPU to compress it further. Also at least one format needs to be allowed, otherwise this call cannot be used. Always allow tgz as that format is a good trade off for all resources. Change-Id: I7177a6135d507f481bb3fa52c46883951030af11 Signed-off-by: Stefan Beller <sbeller@google.com>
This commit is contained in:
@@ -3430,7 +3430,8 @@ get the bundles and then fetch all projects contained in the bundle.
|
||||
(This assumes no non-fastforward pushes).
|
||||
|
||||
You need to give a parameter '?format=zip' or '?format=tar' to specify the
|
||||
format for the outer container.
|
||||
format for the outer container. It is always possible to use tgz, even if
|
||||
tgz is not in the list of allowed archive formats.
|
||||
|
||||
To make good use of this call, you would roughly need code as found at:
|
||||
----
|
||||
|
||||
@@ -75,6 +75,12 @@ public class PreviewSubmit implements RestReadView<RevisionResource> {
|
||||
throw new BadRequestException("format is not specified");
|
||||
}
|
||||
ArchiveFormat f = allowedFormats.extensions.get("." + format);
|
||||
if (f == null && format.equals("tgz")) {
|
||||
// Always allow tgz, even when the allowedFormats doesn't contain it.
|
||||
// Then we allow at least one format even if the list of allowed
|
||||
// formats is empty.
|
||||
f = ArchiveFormat.TGZ;
|
||||
}
|
||||
if (f == null) {
|
||||
throw new BadRequestException("unknown archive format");
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ then
|
||||
fi
|
||||
|
||||
curl --digest -u $gerrituser -w '%{http_code}' -o preview \
|
||||
$server/a/changes/$changeId/revisions/current/preview_submit?format=zip >http_code
|
||||
$server/a/changes/$changeId/revisions/current/preview_submit?format=tgz >http_code
|
||||
if ! grep 200 http_code >/dev/null
|
||||
then
|
||||
# error out:
|
||||
@@ -45,9 +45,9 @@ then
|
||||
cat preview
|
||||
echo
|
||||
else
|
||||
# valid zip file, extract and obtain a bundle for each project
|
||||
# valid tgz file, extract and obtain a bundle for each project
|
||||
mkdir tmp-bundles
|
||||
unzip preview -d tmp-bundles
|
||||
(cd tmp-bundles && tar -zxf ../preview)
|
||||
for project in $(cd tmp-bundles && find -type f)
|
||||
do
|
||||
# Projects may contain slashes, so create the required
|
||||
|
||||
Reference in New Issue
Block a user