From dd4a925013c92011b5c57976c97eb0fa8c7c22d0 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 31 Jan 2014 16:23:11 +0100 Subject: Show error if download for a file is requested that is not writable --- apis/download.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'apis') diff --git a/apis/download.inc.php b/apis/download.inc.php index b9033c6f..898e34ff 100644 --- a/apis/download.inc.php +++ b/apis/download.inc.php @@ -35,7 +35,7 @@ if (isset($_REQUEST['progress'])) { } } fclose($fh); - if ($error === false && $pid > 0 && $percent != 100 && !posix_kill($pid, 0)) $error = 'Process died - ' . $line; + if ($error === false && $pid > 0 && $percent != 100 && !posix_kill($pid, 0)) $error = "Process $pid died - " . file_get_contents($log); if ($error !== false) { echo Render::parse('download-error', array('file' => $file, 'code' => $error)); unlink($log); @@ -80,6 +80,11 @@ if (file_exists($local . '/' . $file) && !$overwrite) { exit(0); } +if (file_exists($local . '/' . $file) && !is_writable($local . '/' . $file)) { + echo Render::parse('download-error', array('file' => $local . '/' . $file, 'remote' => $remote, 'code' => 'Local file is not writable')); + exit(0); +} + if ($directExec) { // Blocking inline download $ret = Util::downloadToFile($local . '/' . $file, $remote . '/' . $file, 20, $code); -- cgit v1.2.3-55-g7522