Archive handler configurability
git-svn-id: file:///home/shish/svn/shimmie2/trunk@643 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
91e3eeff8d
commit
64b9e1e25a
@ -7,9 +7,28 @@
|
|||||||
|
|
||||||
class ArchiveFileHandler extends Extension {
|
class ArchiveFileHandler extends Extension {
|
||||||
public function receive_event($event) {
|
public function receive_event($event) {
|
||||||
|
if(is_a($event, 'InitExtEvent')) {
|
||||||
|
global $config;
|
||||||
|
$config->set_default_string('archive_tmp_dir', "/tmp");
|
||||||
|
$config->set_default_string('archive_extract_command', 'unzip -d "%d" "%f"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_a($event, 'SetupBuildingEvent')) {
|
||||||
|
$sb = new SetupBlock("Archive Handler Options");
|
||||||
|
$sb->add_text_option("archive_tmp_dir", "Temporary folder: ");
|
||||||
|
$sb->add_text_option("archive_extract_command", "<br>Extraction command: ");
|
||||||
|
$sb->add_label("<br>%f for archive, %d for temporary directory");
|
||||||
|
$event->panel->add_block($sb);
|
||||||
|
}
|
||||||
|
|
||||||
if(is_a($event, 'DataUploadEvent') && $this->supported_ext($event->type)) {
|
if(is_a($event, 'DataUploadEvent') && $this->supported_ext($event->type)) {
|
||||||
$tmpdir = "/tmp/shimmie-archive-{$event->hash}";
|
global $config;
|
||||||
system("unzip -d $tmpdir {$event->tmpname}");
|
$tmp = $config->get_string('archive_tmp_dir');
|
||||||
|
$tmpdir = "$tmp/shimmie-archive-{$event->hash}";
|
||||||
|
$cmd = $config->get_string('archive_extract_command');
|
||||||
|
$cmd = str_replace('%f', $event->tmpfile);
|
||||||
|
$cmd = str_replace('%d', $tmpdir);
|
||||||
|
system($cmd);
|
||||||
$this->add_dir($tmpdir);
|
$this->add_dir($tmpdir);
|
||||||
unlink($tmpdir);
|
unlink($tmpdir);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user