Throw lock exceptions if remote share returned 423 status code
This commit is contained in:
parent
fd8f6a18fd
commit
34043d4647
|
@ -219,9 +219,9 @@ class DAV extends Common {
|
||||||
$this->statCache->set($path, false);
|
$this->statCache->set($path, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -286,9 +286,9 @@ class DAV extends Common {
|
||||||
if ($e->getHttpStatus() === 404) {
|
if ($e->getHttpStatus() === 404) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -311,9 +311,9 @@ class DAV extends Common {
|
||||||
if ($e->getHttpStatus() === 404) {
|
if ($e->getHttpStatus() === 404) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -363,6 +363,9 @@ class DAV extends Common {
|
||||||
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
if ($statusCode !== 200) {
|
if ($statusCode !== 200) {
|
||||||
Util::writeLog("webdav client", 'curl GET ' . curl_getinfo($curl, CURLINFO_EFFECTIVE_URL) . ' returned status code ' . $statusCode, Util::ERROR);
|
Util::writeLog("webdav client", 'curl GET ' . curl_getinfo($curl, CURLINFO_EFFECTIVE_URL) . ' returned status code ' . $statusCode, Util::ERROR);
|
||||||
|
if ($statusCode === 423) {
|
||||||
|
throw new \OCP\Lock\LockedException($path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
rewind($fp);
|
rewind($fp);
|
||||||
|
@ -446,10 +449,10 @@ class DAV extends Common {
|
||||||
if ($e->getHttpStatus() === 501) {
|
if ($e->getHttpStatus() === 501) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
return false;
|
return false;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -502,6 +505,9 @@ class DAV extends Common {
|
||||||
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
if ($statusCode !== 200) {
|
if ($statusCode !== 200) {
|
||||||
Util::writeLog("webdav client", 'curl GET ' . curl_getinfo($curl, CURLINFO_EFFECTIVE_URL) . ' returned status code ' . $statusCode, Util::ERROR);
|
Util::writeLog("webdav client", 'curl GET ' . curl_getinfo($curl, CURLINFO_EFFECTIVE_URL) . ' returned status code ' . $statusCode, Util::ERROR);
|
||||||
|
if ($statusCode === 423) {
|
||||||
|
throw new \OCP\Lock\LockedException($path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
fclose($source);
|
fclose($source);
|
||||||
|
@ -564,9 +570,9 @@ class DAV extends Common {
|
||||||
if ($e->getHttpStatus() === 404) {
|
if ($e->getHttpStatus() === 404) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -591,9 +597,9 @@ class DAV extends Common {
|
||||||
if ($e->getHttpStatus() === 404) {
|
if ($e->getHttpStatus() === 404) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -643,9 +649,9 @@ class DAV extends Common {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -763,10 +769,10 @@ class DAV extends Common {
|
||||||
if ($e->getHttpStatus() === 404) {
|
if ($e->getHttpStatus() === 404) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
return false;
|
return false;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->convertException($e);
|
$this->convertException($e, $path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -778,15 +784,19 @@ class DAV extends Common {
|
||||||
* or do nothing.
|
* or do nothing.
|
||||||
*
|
*
|
||||||
* @param Exception $e sabre exception
|
* @param Exception $e sabre exception
|
||||||
|
* @param string $path optional path from the operation
|
||||||
*
|
*
|
||||||
* @throws StorageInvalidException if the storage is invalid, for example
|
* @throws StorageInvalidException if the storage is invalid, for example
|
||||||
* when the authentication expired or is invalid
|
* when the authentication expired or is invalid
|
||||||
* @throws StorageNotAvailableException if the storage is not available,
|
* @throws StorageNotAvailableException if the storage is not available,
|
||||||
* which might be temporary
|
* which might be temporary
|
||||||
*/
|
*/
|
||||||
private function convertException(Exception $e) {
|
private function convertException(Exception $e, $path = '') {
|
||||||
Util::writeLog('files_external', $e->getMessage(), Util::ERROR);
|
Util::writeLog('files_external', $e->getMessage(), Util::ERROR);
|
||||||
if ($e instanceof ClientHttpException) {
|
if ($e instanceof ClientHttpException) {
|
||||||
|
if ($e->getHttpStatus() === 423) {
|
||||||
|
throw new \OCP\Lock\LockedException($path);
|
||||||
|
}
|
||||||
if ($e->getHttpStatus() === 401) {
|
if ($e->getHttpStatus() === 401) {
|
||||||
// either password was changed or was invalid all along
|
// either password was changed or was invalid all along
|
||||||
throw new StorageInvalidException(get_class($e).': '.$e->getMessage());
|
throw new StorageInvalidException(get_class($e).': '.$e->getMessage());
|
||||||
|
|
Loading…
Reference in New Issue