瀏覽代碼

Better error handling

Nathaniel van Diepen 11 年之前
父節點
當前提交
e24795f557
共有 1 個文件被更改,包括 10 次插入2 次删除
  1. 10 2
      install/api.php

+ 10 - 2
install/api.php

@@ -139,9 +139,17 @@
 						$files = scandir(realpath(dirname(__FILE__)));
 						foreach($files as $file){
 							if($file != '.' && $file != '..'){
-								unlink(realpath(dirname(__FILE__)).'/'.$file);
+								try{
+									unlink(realpath(dirname(__FILE__)).'/'.$file);
+								}catch(e){
+									echo "Couldn't remove {$file}\n";
+								}
+							}
+							try{
+								rmdir(realpath(dirname(__FILE__)));
+							}catch(e){
+								echo "Couldn't remove install directory\n";
 							}
-							rmdir(realpath(dirname(__FILE__)));
 						}
 					}else{
 						die('Invalid id');