Mercurial > hg > mgallery
changeset 56:7384504d7b52
Do not prompt for deletion in cleanup if there are no files/directories to delete.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 12 Sep 2016 13:50:24 +0300 |
parents | b1fa4fd593d1 |
children | 29bb365e3ee2 |
files | mgtool.php |
diffstat | 1 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mgtool.php Mon Sep 12 13:49:52 2016 +0300 +++ b/mgtool.php Mon Sep 12 13:50:24 2016 +0300 @@ -297,7 +297,7 @@ function mgDelete($path, $recurse) { - global $flagDoDelete; + global $flagDoDelete, $countDoDelete; if (is_dir($path)) { if (($dirHandle = @opendir($path)) === FALSE) @@ -312,15 +312,22 @@ echo " - ".$path." [DIR]\n"; if ($flagDoDelete) + { + $countDoDelete++; rmdir($path); + } } else if (file_exists($path)) { if (!$recurse) echo " - ".$path."\n"; + if ($flagDoDelete) + { + $countDoDelete++; unlink($path); + } } } @@ -797,9 +804,15 @@ default: mgFatal("Invalid clean mode '".mgCArg(2)."'.\n"); } + $countDoDelete = 0; $flagDoDelete = FALSE; mgProcessGalleries(GCMD_CLEAN, mgCArg(3)); echo "--\n"; + if ($countDoDelete == 0) + { + echo "Nothing to clean!\n"; + } + else if (mgYesNoPrompt("Really delete the above files and directories?")) { echo "Deleting ...\n";