Skip to content

Commit

Permalink
Downstream 2016-06-09
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://github.com/owncloud/core into downstream-160609
  • Loading branch information
blizzz committed Jun 9, 2016
2 parents 2819373 + 6ba1893 commit a636e4f
Show file tree
Hide file tree
Showing 102 changed files with 1,210 additions and 270 deletions.
4 changes: 2 additions & 2 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
RewriteRule ^remote/(.*) remote.php [QSA,L]
RewriteRule ^(build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*
RewriteRule ^(\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
RewriteRule ^(?:\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
</IfModule>
<IfModule mod_mime.c>
AddType image/svg+xml svg svgz
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ protected function validateUserPass($username, $password) {
$this->session->close();
return true;
} else {
\OC_Util::setUpFS(); //login hooks may need early access to the filesystem
\OC_Util::setupFS(); //login hooks may need early access to the filesystem
if($this->userSession->logClientIn($username, $password)) {
$this->userSession->createSessionToken($this->request, $this->userSession->getUser()->getUID(), $username, $password);
\OC_Util::setUpFS($this->userSession->getUser()->getUID());
\OC_Util::setupFS($this->userSession->getUser()->getUID());
$this->session->set(self::DAV_AUTHENTICATED, $this->userSession->getUser()->getUID());
$this->session->close();
return true;
Expand Down
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;"
}
1 change: 1 addition & 0 deletions apps/federatedfilesharing/l10n/pl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ OC.L10N.register(
"federatedfilesharing",
{
"Sharing %s failed, because this item is already shared with %s" : "Współdzielenie %s nie powiodło się, ponieważ element jest już współdzielony z %s",
"File is already shared with %s" : "Plik jest już współdzielony z %s",
"Sharing %s failed, could not find %s, maybe the server is currently unreachable." : "Współdzielenie %s nie powiodło się, nie można odnaleźć %s. Prawdopobnie serwer nie jest teraz osiągalny.",
"Accept" : "Akceptuj",
"Open documentation" : "Otwórz dokumentację",
Expand Down
1 change: 1 addition & 0 deletions apps/federatedfilesharing/l10n/pl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ "translations": {
"Sharing %s failed, because this item is already shared with %s" : "Współdzielenie %s nie powiodło się, ponieważ element jest już współdzielony z %s",
"File is already shared with %s" : "Plik jest już współdzielony z %s",
"Sharing %s failed, could not find %s, maybe the server is currently unreachable." : "Współdzielenie %s nie powiodło się, nie można odnaleźć %s. Prawdopobnie serwer nie jest teraz osiągalny.",
"Accept" : "Akceptuj",
"Open documentation" : "Otwórz dokumentację",
Expand Down
11 changes: 7 additions & 4 deletions apps/federation/css/settings-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
cursor: pointer;
}

#listOfTrustedServers li:hover {
cursor: pointer;
}

#listOfTrustedServers .status {
margin-right: 10px;
}

#listOfTrustedServers .icon {
cursor: pointer;
display: inline-block;
vertical-align: middle;
margin-left: 10px;
}
13 changes: 7 additions & 6 deletions apps/federation/js/settings-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ $(document).ready(function () {
$('ul#listOfTrustedServers').prepend(
$('<li>')
.attr('id', data.id)
.attr('class', 'icon-delete')
.html('<span class="status indeterminate"></span>' + data.url)
.html('<span class="status indeterminate"></span>' +
data.url +
'<span class="icon icon-delete"></span>')
);
OC.msg.finishedSuccess('#ocFederationAddServer .msg', data.message);
})
Expand All @@ -56,10 +57,10 @@ $(document).ready(function () {
}
});

// remove trusted server from list
$( "#listOfTrustedServers" ).on('click', 'li', function() {
var id = $(this).attr('id');
var $this = $(this);
// remove trusted server from list
$( "#listOfTrustedServers" ).on('click', 'li > .icon-delete', function() {
var $this = $(this).parent();
id = $this.attr('id');
$.ajax({
url: OC.generateUrl('/apps/federation/trusted-servers/' + id),
type: 'DELETE',
Expand Down
3 changes: 2 additions & 1 deletion apps/federation/templates/settings-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</p>
<ul id="listOfTrustedServers">
<?php foreach($_['trustedServers'] as $trustedServer) { ?>
<li id="<?php p($trustedServer['id']); ?>" class="icon-delete">
<li id="<?php p($trustedServer['id']); ?>">
<?php if((int)$trustedServer['status'] === TrustedServers::STATUS_OK) { ?>
<span class="status success"></span>
<?php
Expand All @@ -36,6 +36,7 @@
<span class="status error"></span>
<?php } ?>
<?php p($trustedServer['url']); ?>
<span class="icon icon-delete"></span>
</li>
<?php } ?>
</ul>
Expand Down
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
Loading

0 comments on commit a636e4f

Please sign in to comment.