Skip to content

Commit

Permalink
Return 403 instead of 503 to resume syncing of desktop client
Browse files Browse the repository at this point in the history
When 503 is returned the syncing is stopped
by desktop client. Hence its found better
to return 403.

Signed-off-by: Sujith H <[email protected]>
  • Loading branch information
sharidas committed Jan 10, 2018
1 parent 412f756 commit 2ddad25
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ public function get() {
}
return $res;
} catch (GenericEncryptionException $e) {
// returning 503 will allow retry of the operation at a later point in time
throw new ServiceUnavailable("Encryption not ready: " . $e->getMessage());
// returning 403 because some apps stops syncing if 503 is returned.
throw new Forbidden("Encryption not ready: " . $e->getMessage());
} catch (StorageNotAvailableException $e) {
throw new ServiceUnavailable("Failed to open file: " . $e->getMessage());
} catch (ForbiddenException $ex) {
Expand Down
25 changes: 25 additions & 0 deletions apps/dav/tests/unit/Connector/Sabre/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OC\Files\Storage\Local;
use OC\Files\View;
use OCA\DAV\Connector\Sabre\Exception\FileLocked;
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
use OCA\DAV\Connector\Sabre\File;
use OCP\Constants;
use OCP\Encryption\Exceptions\GenericEncryptionException;
Expand Down Expand Up @@ -1257,6 +1258,30 @@ public function testGetFopenThrows() {
$file->get();
}

/**
* @expectedException \Sabre\Dav\Exception\Forbidden
* @expectedExceptionMessage Encryption not ready
*/
public function testFopenForbiddenExceptionEncryption() {
$view = $this->getMockBuilder(View::class)
->setMethods(['fopen', 'file_exists'])
->getMock();
$view->expects($this->atLeastOnce())
->method('fopen')
->willThrowException(new Exception\Forbidden('Encryption not ready', true));
$view->expects($this->atLeastOnce())
->method('file_exists')
->will($this->returnValue(true));

$info = new FileInfo('/test.txt', $this->getMockStorage(), null, [
'permissions' => Constants::PERMISSION_ALL
], null);

$file = new File($view, $info);

$file->get();
}

/**
* @expectedException \Sabre\DAV\Exception\NotFound
*/
Expand Down

0 comments on commit 2ddad25

Please sign in to comment.