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:
@@ -449,17 +449,18 @@ class IDF_Scm_Mercurial extends IDF_Scm
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the command to create a zip archive at a given commit.
|
||||
* Generate a zip archive at a given commit.
|
||||
*
|
||||
* @param string Commit
|
||||
* @param string Prefix ('git-repo-dump')
|
||||
* @return string Command
|
||||
* @return Pluf_HTTP_Response The HTTP response containing the zip archive
|
||||
*/
|
||||
public function getArchiveCommand($commit, $prefix='')
|
||||
protected function getArchiveStream($commit, $prefix='')
|
||||
{
|
||||
return sprintf(Pluf::f('idf_exec_cmd_prefix', '').
|
||||
$cmd = sprintf(Pluf::f('idf_exec_cmd_prefix', '').
|
||||
Pluf::f('hg_path', 'hg').' archive --type=zip -R %s -r %s -',
|
||||
escapeshellarg($this->repo),
|
||||
escapeshellarg($commit));
|
||||
return new Pluf_HTTP_Response_CommandPassThru($cmd, 'application/x-zip');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user