From 8ae2b52e4db45f26c32a4ad9bc65494480936cbf Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 7 Nov 2013 17:10:43 +0100 Subject: Make download work --- apis/download.inc.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'apis') diff --git a/apis/download.inc.php b/apis/download.inc.php index 9ba0f008..4be67521 100644 --- a/apis/download.inc.php +++ b/apis/download.inc.php @@ -21,13 +21,19 @@ case 'tgz': default: die('Invalid download type'); } +@mkdir($local, 0755, true); if (file_exists($local . '/' . $file) && !isset($_REQUEST['exec'])) { - echo 'FILE EXISTS LOCALLY I SHOULD ASK FOR OVERWRITE NOW'; + echo Render::parse('download-overwrite', array('file' => $file, 'id' => $id, 'query' => $_SERVER['REQUEST_URI']));; exit(0); } -sleep(2); +$ret = Util::downloadToFile($local . '/' . $file, $remote . '/' . $file, 20, $code); +if ($ret === false || $code < 200 || $code >= 300) { + @unlink($local . '/' . $file); + echo Render::parse('download-error', array('file' => $file, 'remote' => $remote, 'code' => $code)); + exit(0); +} // No execution - just return dialog echo Render::parse('download-complete', array('file' => $file)); -- cgit v1.2.3-55-g7522