diff options
Diffstat (limited to 'apis')
-rw-r--r-- | apis/download.inc.php | 10 |
1 files changed, 8 insertions, 2 deletions
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)); |