Skip to content

Commit

Permalink
Merge pull request #25 from nextcloud/downstream-160608
Browse files Browse the repository at this point in the history
Downstream 2016-06-08
  • Loading branch information
MorrisJobke committed Jun 9, 2016
2 parents b928305 + bb67acf commit fc3ad7d
Show file tree
Hide file tree
Showing 57 changed files with 743 additions and 171 deletions.
2 changes: 2 additions & 0 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ public function getChild($name, $info = null) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
} catch (\OCP\Files\InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage());
} catch (ForbiddenException $e) {
throw new \Sabre\DAV\Exception\Forbidden();
}
}

Expand Down
9 changes: 4 additions & 5 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,19 @@ public function initialize(\Sabre\DAV\Server $server) {
*/
function checkMove($source, $destination) {
$sourceNode = $this->tree->getNodeForPath($source);
if ($sourceNode instanceof FutureFile) {
if (!$sourceNode instanceof Node) {
return;
}
list($sourceDir,) = \Sabre\HTTP\URLUtil::splitPath($source);
list($destinationDir,) = \Sabre\HTTP\URLUtil::splitPath($destination);

if ($sourceDir !== $destinationDir) {
$sourceFileInfo = $this->fileView->getFileInfo($source);

if ($sourceFileInfo === false) {
$sourceNodeFileInfo = $sourceNode->getFileInfo();
if (is_null($sourceNodeFileInfo)) {
throw new NotFound($source . ' does not exist');
}

if (!$sourceFileInfo->isDeletable()) {
if (!$sourceNodeFileInfo->isDeletable()) {
throw new Forbidden($source . " cannot be deleted");
}
}
Expand Down
4 changes: 4 additions & 0 deletions apps/dav/lib/Connector/Sabre/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,8 @@ public function releaseLock($type) {
public function changeLock($type) {
$this->fileView->changeLock($this->path, $type);
}

public function getFileInfo() {
return $this->info;
}
}
2 changes: 2 additions & 0 deletions apps/dav/lib/Connector/Sabre/ObjectTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ public function getNodeForPath($path) {
throw new \Sabre\DAV\Exception\NotFound('Storage ' . $path . ' is invalid');
} catch (LockedException $e) {
throw new \Sabre\DAV\Exception\Locked();
} catch (ForbiddenException $e) {
throw new \Sabre\DAV\Exception\Forbidden();
}
}

Expand Down
60 changes: 38 additions & 22 deletions apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
namespace OCA\DAV\Tests\unit\Connector\Sabre;

use OCA\DAV\Connector\Sabre\FilesPlugin;
use OCP\Files\StorageNotAvailableException;
use Sabre\DAV\PropFind;
use Sabre\DAV\PropPatch;
Expand All @@ -36,16 +37,16 @@
* See the COPYING-README file.
*/
class FilesPluginTest extends TestCase {
const GETETAG_PROPERTYNAME = \OCA\DAV\Connector\Sabre\FilesPlugin::GETETAG_PROPERTYNAME;
const FILEID_PROPERTYNAME = \OCA\DAV\Connector\Sabre\FilesPlugin::FILEID_PROPERTYNAME;
const INTERNAL_FILEID_PROPERTYNAME = \OCA\DAV\Connector\Sabre\FilesPlugin::INTERNAL_FILEID_PROPERTYNAME;
const SIZE_PROPERTYNAME = \OCA\DAV\Connector\Sabre\FilesPlugin::SIZE_PROPERTYNAME;
const PERMISSIONS_PROPERTYNAME = \OCA\DAV\Connector\Sabre\FilesPlugin::PERMISSIONS_PROPERTYNAME;
const LASTMODIFIED_PROPERTYNAME = \OCA\DAV\Connector\Sabre\FilesPlugin::LASTMODIFIED_PROPERTYNAME;
const DOWNLOADURL_PROPERTYNAME = \OCA\DAV\Connector\Sabre\FilesPlugin::DOWNLOADURL_PROPERTYNAME;
const OWNER_ID_PROPERTYNAME = \OCA\DAV\Connector\Sabre\FilesPlugin::OWNER_ID_PROPERTYNAME;
const OWNER_DISPLAY_NAME_PROPERTYNAME = \OCA\DAV\Connector\Sabre\FilesPlugin::OWNER_DISPLAY_NAME_PROPERTYNAME;
const DATA_FINGERPRINT_PROPERTYNAME = \OCA\DAV\Connector\Sabre\FilesPlugin::DATA_FINGERPRINT_PROPERTYNAME;
const GETETAG_PROPERTYNAME = FilesPlugin::GETETAG_PROPERTYNAME;
const FILEID_PROPERTYNAME = FilesPlugin::FILEID_PROPERTYNAME;
const INTERNAL_FILEID_PROPERTYNAME = FilesPlugin::INTERNAL_FILEID_PROPERTYNAME;
const SIZE_PROPERTYNAME = FilesPlugin::SIZE_PROPERTYNAME;
const PERMISSIONS_PROPERTYNAME = FilesPlugin::PERMISSIONS_PROPERTYNAME;
const LASTMODIFIED_PROPERTYNAME = FilesPlugin::LASTMODIFIED_PROPERTYNAME;
const DOWNLOADURL_PROPERTYNAME = FilesPlugin::DOWNLOADURL_PROPERTYNAME;
const OWNER_ID_PROPERTYNAME = FilesPlugin::OWNER_ID_PROPERTYNAME;
const OWNER_DISPLAY_NAME_PROPERTYNAME = FilesPlugin::OWNER_DISPLAY_NAME_PROPERTYNAME;
const DATA_FINGERPRINT_PROPERTYNAME = FilesPlugin::DATA_FINGERPRINT_PROPERTYNAME;

/**
* @var \Sabre\DAV\Server | \PHPUnit_Framework_MockObject_MockObject
Expand All @@ -58,7 +59,7 @@ class FilesPluginTest extends TestCase {
private $tree;

/**
* @var \OCA\DAV\Connector\Sabre\FilesPlugin
* @var FilesPlugin
*/
private $plugin;

Expand All @@ -84,11 +85,11 @@ public function setUp() {
->disableOriginalConstructor()
->getMock();
$this->config = $this->getMock('\OCP\IConfig');
$this->config->method('getSystemValue')
$this->config->expects($this->any())->method('getSystemValue')
->with($this->equalTo('data-fingerprint'), $this->equalTo(''))
->willReturn('my_fingerprint');

$this->plugin = new \OCA\DAV\Connector\Sabre\FilesPlugin(
$this->plugin = new FilesPlugin(
$this->tree,
$this->view,
$this->config
Expand Down Expand Up @@ -263,7 +264,7 @@ public function testGetPropertiesStorageNotAvailable() {
}

public function testGetPublicPermissions() {
$this->plugin = new \OCA\DAV\Connector\Sabre\FilesPlugin(
$this->plugin = new FilesPlugin(
$this->tree,
$this->view,
$this->config,
Expand Down Expand Up @@ -331,7 +332,7 @@ public function testGetPropertiesForRootDirectory() {
$node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor()
->getMock();
$node->method('getPath')->willReturn('/');
$node->expects($this->any())->method('getPath')->willReturn('/');

$propFind = new PropFind(
'/',
Expand Down Expand Up @@ -432,11 +433,16 @@ public function testMoveSrcNotDeletable() {
->method('isDeletable')
->willReturn(false);

$this->view->expects($this->once())
$node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node')
->disableOriginalConstructor()
->getMock();
$node->expects($this->once())
->method('getFileInfo')
->with('FolderA/test.txt')
->willReturn($fileInfoFolderATestTXT);

$this->tree->expects($this->once())->method('getNodeForPath')
->willReturn($node);

$this->plugin->checkMove('FolderA/test.txt', 'test.txt');
}

Expand All @@ -448,11 +454,16 @@ public function testMoveSrcDeletable() {
->method('isDeletable')
->willReturn(true);

$this->view->expects($this->once())
$node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node')
->disableOriginalConstructor()
->getMock();
$node->expects($this->once())
->method('getFileInfo')
->with('FolderA/test.txt')
->willReturn($fileInfoFolderATestTXT);

$this->tree->expects($this->once())->method('getNodeForPath')
->willReturn($node);

$this->plugin->checkMove('FolderA/test.txt', 'test.txt');
}

Expand All @@ -461,10 +472,15 @@ public function testMoveSrcDeletable() {
* @expectedExceptionMessage FolderA/test.txt does not exist
*/
public function testMoveSrcNotExist() {
$this->view->expects($this->once())
$node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node')
->disableOriginalConstructor()
->getMock();
$node->expects($this->once())
->method('getFileInfo')
->with('FolderA/test.txt')
->willReturn(false);
->willReturn(null);

$this->tree->expects($this->once())->method('getNodeForPath')
->willReturn($node);

$this->plugin->checkMove('FolderA/test.txt', 'test.txt');
}
Expand Down
59 changes: 59 additions & 0 deletions apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* @author Joas Schilling <nickvergessen@owncloud.com>
* @author Robin Appelman <icewind@owncloud.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @copyright Copyright (c) 2016, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;

use OC\Connector\Sabre\Exception\FileLocked;
use OCP\AppFramework\Http;
use OCP\Lock\ILockingProvider;

/**
* Class DeleteTest
*
* @group DB
*
* @package OCA\DAV\Tests\unit\Connector\Sabre\RequestTest
*/
class DeleteTest extends RequestTest {
public function testBasicUpload() {
$user = $this->getUniqueID();
$view = $this->setupUser($user, 'pass');

$view->file_put_contents('foo.txt', 'asd');
$mount = $view->getMount('foo.txt');
$internalPath = $view->getAbsolutePath();

// create a ghost file
$mount->getStorage()->unlink($mount->getInternalPath($internalPath));

// cache entry still exists
$this->assertInstanceOf('\OCP\Files\FileInfo', $view->getFileInfo('foo.txt'));

$response = $this->request($view, $user, 'pass', 'DELETE', '/foo.txt');

$this->assertEquals(Http::STATUS_NO_CONTENT, $response->getStatus());

// no longer in the cache
$this->assertFalse($view->getFileInfo('foo.txt'));
}
}
6 changes: 6 additions & 0 deletions apps/federatedfilesharing/l10n/ar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
OC.L10N.register(
"federatedfilesharing",
{
"Invalid Federated Cloud ID" : "معرّف السحابة المتحدة غير صالح"
},
"nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;");
4 changes: 4 additions & 0 deletions apps/federatedfilesharing/l10n/ar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ "translations": {
"Invalid Federated Cloud ID" : "معرّف السحابة المتحدة غير صالح"
},"pluralForm" :"nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;"
}
3 changes: 3 additions & 0 deletions apps/files/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
this.$showHiddenFiles = $('input#showhiddenfilesToggle');
var showHidden = $('#showHiddenFiles').val() === "1";
this.$showHiddenFiles.prop('checked', showHidden);
if ($('#fileNotFound').val() === "1") {
OC.Notification.showTemporary(t('files', 'File could not be found'));
}

this._filesConfig = new OC.Backbone.Model({
showhidden: showHidden
Expand Down
6 changes: 6 additions & 0 deletions apps/files/l10n/da.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ OC.L10N.register(
"Could not get result from server." : "Kunne ikke hente resultat fra server.",
"Uploading..." : "Uploader...",
"..." : "...",
"Any moment now..." : "Når som helst...",
"Soon..." : "Snart...",
"File upload is in progress. Leaving the page now will cancel the upload." : "Fil upload kører. Hvis du forlader siden nu, vil uploadet blive annuleret.",
"Actions" : "Handlinger",
"Download" : "Download",
Expand All @@ -47,6 +49,8 @@ OC.L10N.register(
"This directory is unavailable, please check the logs or contact the administrator" : "Denne mappe er utilgængelig, tjek venligst loggene eller kontakt administratoren",
"Could not move \"{file}\", target exists" : "Kunne ikke flytte \"{file}\" - der findes allerede en fil med dette navn",
"Could not move \"{file}\"" : "Kunne ikke flytte \"{file}\"",
"{newName} already exists" : "{newName} eksistere allerede",
"Error deleting file \"{fileName}\"." : "Fejl under sletning af filen \"{fileName}\"",
"No entries in this folder match '{filter}'" : "Der er ingen poster i denne mappe, der matcher '{filter}'",
"Name" : "Navn",
"Size" : "Størrelse",
Expand All @@ -68,6 +72,7 @@ OC.L10N.register(
"_%n byte_::_%n bytes_" : ["%n byte","%n bytes"],
"Favorited" : "Gjort til foretrukken",
"Favorite" : "Foretrukken",
"Local link" : "Lokalt link",
"Folder" : "Mappe",
"New folder" : "Ny Mappe",
"{newname} already exists" : "{newname} eksistere allerede",
Expand Down Expand Up @@ -97,6 +102,7 @@ OC.L10N.register(
"Save" : "Gem",
"Missing permissions to edit from here." : "Rettighed mangler til at redigere på dette sted",
"Settings" : "Indstillinger",
"Show hidden files" : "Vis skjulte filer",
"WebDAV" : "WebDAV",
"No files in here" : "Her er ingen filer",
"Upload some content or sync with your devices!" : "Overfør indhold eller synkronisér med dine enheder!",
Expand Down
6 changes: 6 additions & 0 deletions apps/files/l10n/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"Could not get result from server." : "Kunne ikke hente resultat fra server.",
"Uploading..." : "Uploader...",
"..." : "...",
"Any moment now..." : "Når som helst...",
"Soon..." : "Snart...",
"File upload is in progress. Leaving the page now will cancel the upload." : "Fil upload kører. Hvis du forlader siden nu, vil uploadet blive annuleret.",
"Actions" : "Handlinger",
"Download" : "Download",
Expand All @@ -45,6 +47,8 @@
"This directory is unavailable, please check the logs or contact the administrator" : "Denne mappe er utilgængelig, tjek venligst loggene eller kontakt administratoren",
"Could not move \"{file}\", target exists" : "Kunne ikke flytte \"{file}\" - der findes allerede en fil med dette navn",
"Could not move \"{file}\"" : "Kunne ikke flytte \"{file}\"",
"{newName} already exists" : "{newName} eksistere allerede",
"Error deleting file \"{fileName}\"." : "Fejl under sletning af filen \"{fileName}\"",
"No entries in this folder match '{filter}'" : "Der er ingen poster i denne mappe, der matcher '{filter}'",
"Name" : "Navn",
"Size" : "Størrelse",
Expand All @@ -66,6 +70,7 @@
"_%n byte_::_%n bytes_" : ["%n byte","%n bytes"],
"Favorited" : "Gjort til foretrukken",
"Favorite" : "Foretrukken",
"Local link" : "Lokalt link",
"Folder" : "Mappe",
"New folder" : "Ny Mappe",
"{newname} already exists" : "{newname} eksistere allerede",
Expand Down Expand Up @@ -95,6 +100,7 @@
"Save" : "Gem",
"Missing permissions to edit from here." : "Rettighed mangler til at redigere på dette sted",
"Settings" : "Indstillinger",
"Show hidden files" : "Vis skjulte filer",
"WebDAV" : "WebDAV",
"No files in here" : "Her er ingen filer",
"Upload some content or sync with your devices!" : "Overfør indhold eller synkronisér med dine enheder!",
Expand Down
Loading

0 comments on commit fc3ad7d

Please sign in to comment.