Rework the way IDF's SCM interface provides downloadable snapshots.

Instead of returning a command which gets executed and which should
pass through / stream its output data to the client, we're just
returning an instance of Pluf_HTTP_Response. This is needed, because
some SCMs, most noticable monotone, have no locally executable command
to provide a snapshot archive (and probably never will for our kind
of setup).

We therefor added a little BSD-licensed class "ZipArchive" which allows
the creation of pkzip-compatible archives on the fly by letting it eat
the file contents directly feed from the (remote) stdio instance.
Download performance is ok and lies between 15K/s and 110K/s, but at
least we do no longer block the browser while we pre-generate the zip
file server-side.

Thanks to Patrick Georgi for all his work!
This commit is contained in:
Thomas Keller
2010-10-30 21:52:40 +00:00
parent 8a55952204
commit fe001abd26
13 changed files with 3875 additions and 15 deletions

View File

@@ -21,8 +21,8 @@
#
# ***** END LICENSE BLOCK ***** */
require_once(dirname(__FILE__) . "/Monotone/Stdio.php");
require_once(dirname(__FILE__) . "/Monotone/BasicIO.php");
//require_once(dirname(__FILE__) . "/Monotone/Stdio.php");
//require_once(dirname(__FILE__) . "/Monotone/BasicIO.php");
/**
* Monotone scm class
@@ -135,6 +135,20 @@ class IDF_Scm_Monotone extends IDF_Scm
return $branch;
}
/**
* @see IDF_Scm::getArchiveStream
*/
public function getArchiveStream($commit, $prefix='repository/')
{
$revs = $this->_resolveSelector($commit);
// sanity: this should actually not happen, because the
// revision is validated before already
if (count($revs) == 0) {
return new Pluf_HTTP_Response_NotFound();
}
return new IDF_Scm_Monotone_ZipRender($this->stdio, $revs[0]);
}
/**
* expands a selector or a partial revision id to zero, one or
* multiple 40 byte revision ids