Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return 403 instead of 503 to resume syncing of desktop client #30059

Merged
merged 1 commit into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PVince81 Created a function to check the get() call making Forbidden exception. Earlier change set can be ignored.

$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