Fix catching invalid type when deleting a folder

This commit is contained in:
Robin Appelman 2014-07-21 19:42:03 +02:00
commit 1a3640e25b

View file

@ -144,7 +144,20 @@ class Share implements IShare {
* @return bool * @return bool
*/ */
public function del($path) { public function del($path) {
return $this->simpleCommand('del', $path); //del return a file not found error when trying to delete a folder
//we catch it so we can check if $path doesn't exist or is of invalid type
try {
return $this->simpleCommand('del', $path);
} catch (NotFoundException $e) {
//no need to do anything with the result, we just check if this throws the not found error
try {
$this->simpleCommand('ls', $path);
} catch (NotFoundException $e2) {
throw $e;
} catch (\Exception $e2) {
throw new InvalidTypeException();
}
}
} }
/** /**
@ -272,7 +285,7 @@ class Share implements IShare {
case ErrorCodes::NotADirectory: case ErrorCodes::NotADirectory:
throw new InvalidTypeException(); throw new InvalidTypeException();
default: default:
throw new \Exception(); throw new Exception();
} }
} }
} }