Commit f01e7f97 authored by anarcat's avatar anarcat Committed by anarcat

make switch_path work if one of the paths is missing, return proper error values

parent e287e7f0
......@@ -226,24 +226,29 @@ function provision_path_chgrp_recursive($path, &$gid, &$reason) {
function provision_path_switch_paths($path1, &$path2, &$reason) {
//TODO : Add error reasons.
$temp = $path1 .'.tmp';
if (rename($path1, $temp)) {
if (!file_exists($path1)) {
return rename($path2, $path1);
}
elseif (!file_exists($path2)) {
return rename($path1, $path2);
}
elseif (rename($path1, $temp)) {
if (rename($path2, $path1)) {
if (rename($temp, $path2)) {
return $path2; // path1 is now path2
}
else {
// same .. just in reverse
rename($path1, $path2);
rename($temp, $path1);
return rename($path1, $path2) && rename($temp, $path1);
}
}
else {
// same .. just in reverse
rename($temp, $path1);
return rename($temp, $path1);
}
}
return $path1;
return FALSE;
}
function provision_path_extract($path, &$target, &$reason) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment