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 cdb9e53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 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
9 changes: 7 additions & 2 deletions apps/dav/tests/unit/Connector/Sabre/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ public function fopenFailuresProvider() {
],
[
new GenericEncryptionException(),
'Sabre\DAV\Exception\ServiceUnavailable'
'Sabre\DAV\Exception\ServiceUnavailable',
true,
"Encryption not ready: Unspecified encryption exception"
],
[
new StorageNotAvailableException(),
Expand All @@ -175,7 +177,7 @@ public function fopenFailuresProvider() {
/**
* @dataProvider fopenFailuresProvider
*/
public function testSimplePutFails($thrownException, $expectedException, $checkPreviousClass = true) {
public function testSimplePutFails($thrownException, $expectedException, $checkPreviousClass = true, $exceptionMessage = null) {
// setup
$storage = $this->getMockBuilder(Local::class)
->setMethods(['fopen'])
Expand Down Expand Up @@ -227,6 +229,9 @@ function ($path) use ($storage) {
if ($checkPreviousClass) {
$this->assertInstanceOf(get_class($thrownException), $caughtException->getPrevious());
}
if ($exceptionMessage !== null) {
$this->assertEquals($exceptionMessage, $caughtException->getMessage());
}

$this->assertEmpty($this->listPartFiles($view, ''), 'No stray part files');
}
Expand Down

0 comments on commit cdb9e53

Please sign in to comment.