aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/js/filelist.js9
-rw-r--r--apps/files_sharing/lib/external/mount.php1
-rw-r--r--apps/files_sharing/lib/helper.php1
-rw-r--r--apps/files_sharing/lib/sharedmount.php10
-rw-r--r--apps/files_sharing/lib/updater.php23
-rw-r--r--apps/files_sharing/tests/updater.php36
-rw-r--r--core/css/styles.css5
-rw-r--r--lib/private/files/objectstore/homeobjectstorestorage.php2
-rw-r--r--lib/private/files/storage/home.php2
-rw-r--r--lib/private/files/view.php41
-rw-r--r--lib/public/files/storage.php4
11 files changed, 113 insertions, 21 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 94f161943a1..400e3e28f00 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -675,8 +675,13 @@
}).text(simpleSize);
tr.append(td);
- // date column
- var modifiedColor = Math.round((Math.round((new Date()).getTime() / 1000) - mtime)/60/60/24*5);
+ // date column (1000 milliseconds to seconds, 60 seconds, 60 minutes, 24 hours)
+ // difference in days multiplied by 5 - brightest shade for files older than 32 days (160/5)
+ var modifiedColor = Math.round(((new Date()).getTime() - mtime )/1000/60/60/24*5 );
+ // ensure that the brightest color is still readable
+ if (modifiedColor >= '160') {
+ modifiedColor = 160;
+ }
td = $('<td></td>').attr({ "class": "date" });
td.append($('<span></span>').attr({
"class": "modified",
diff --git a/apps/files_sharing/lib/external/mount.php b/apps/files_sharing/lib/external/mount.php
index a42a12f9b9a..e564dded69a 100644
--- a/apps/files_sharing/lib/external/mount.php
+++ b/apps/files_sharing/lib/external/mount.php
@@ -38,6 +38,7 @@ class Mount extends \OC\Files\Mount\Mount implements MoveableMount {
public function moveMount($target) {
$result = $this->manager->setMountPoint($this->mountPoint, $target);
$this->setMountPoint($target);
+
return $result;
}
diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php
index 0b3433576f6..c15b1d48114 100644
--- a/apps/files_sharing/lib/helper.php
+++ b/apps/files_sharing/lib/helper.php
@@ -236,4 +236,5 @@ class Helper {
$result = $appConfig->getValue('files_sharing', 'incoming_server2server_share_enabled', 'yes');
return ($result === 'yes') ? true : false;
}
+
}
diff --git a/apps/files_sharing/lib/sharedmount.php b/apps/files_sharing/lib/sharedmount.php
index 8d0ecbc6789..f8def2c6a82 100644
--- a/apps/files_sharing/lib/sharedmount.php
+++ b/apps/files_sharing/lib/sharedmount.php
@@ -8,10 +8,8 @@
namespace OCA\Files_Sharing;
-use OC\Files\Filesystem;
use OC\Files\Mount\Mount;
use OC\Files\Mount\MoveableMount;
-use OC\Files\Storage\Shared;
/**
* Shared mount points can be moved by the user
@@ -119,14 +117,6 @@ class SharedMount extends Mount implements MoveableMount {
* @return bool
*/
public function moveMount($target) {
- // it shouldn't be possible to move a Shared storage into another one
- list($targetStorage,) = Filesystem::resolvePath($target);
- if ($targetStorage instanceof Shared) {
- \OCP\Util::writeLog('file sharing',
- 'It is not allowed to move one mount point into another one',
- \OCP\Util::DEBUG);
- return false;
- }
$relTargetPath = $this->stripUserFilesPath($target);
$share = $this->storage->getShare();
diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php
index e114c3ba0ac..aac4ed196de 100644
--- a/apps/files_sharing/lib/updater.php
+++ b/apps/files_sharing/lib/updater.php
@@ -109,6 +109,7 @@ class Shared_Updater {
static public function renameHook($params) {
self::correctFolders($params['newpath']);
self::correctFolders(pathinfo($params['oldpath'], PATHINFO_DIRNAME));
+ self::renameChildren($params['oldpath'], $params['newpath']);
}
/**
@@ -209,4 +210,26 @@ class Shared_Updater {
$findAndRemoveShares->execute(array());
}
+ /**
+ * rename mount point from the children if the parent was renamed
+ *
+ * @param string $oldPath old path relative to data/user/files
+ * @param string $newPath new path relative to data/user/files
+ */
+ static private function renameChildren($oldPath, $newPath) {
+
+ $absNewPath = \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $newPath);
+ $absOldPath = \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $oldPath);
+
+ $mountManager = \OC\Files\Filesystem::getMountManager();
+ $mountedShares = $mountManager->findIn('/' . \OCP\User::getUser() . '/files/' . $oldPath);
+ foreach ($mountedShares as $mount) {
+ if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
+ $mountPoint = $mount->getMountPoint();
+ $target = str_replace($absOldPath, $absNewPath, $mountPoint);
+ $mount->moveMount($target);
+ }
+ }
+ }
+
}
diff --git a/apps/files_sharing/tests/updater.php b/apps/files_sharing/tests/updater.php
index cdb44068254..5ec53488702 100644
--- a/apps/files_sharing/tests/updater.php
+++ b/apps/files_sharing/tests/updater.php
@@ -217,4 +217,40 @@ class Test_Files_Sharing_Updater extends Test_Files_Sharing_Base {
}
+ /**
+ * if a folder gets renamed all children mount points should be renamed too
+ */
+ function testRename() {
+
+ $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
+ $result = \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
+ $this->assertTrue($result);
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
+
+ // make sure that the shared folder exists
+ $this->assertTrue(\OC\Files\Filesystem::file_exists($this->folder));
+
+ \OC\Files\Filesystem::mkdir('oldTarget');
+ \OC\Files\Filesystem::mkdir('oldTarget/subfolder');
+ \OC\Files\Filesystem::mkdir('newTarget');
+
+ \OC\Files\Filesystem::rename($this->folder, 'oldTarget/subfolder/' . $this->folder);
+
+ // re-login to make sure that the new mount points are initialized
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
+
+ \OC\Files\Filesystem::rename('/oldTarget', '/newTarget/oldTarget');
+
+ // re-login to make sure that the new mount points are initialized
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
+
+ $this->assertTrue(\OC\Files\Filesystem::file_exists('/newTarget/oldTarget/subfolder/' . $this->folder));
+
+ // cleanup
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
+ $result = \OCP\Share::unshare('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $this->assertTrue($result);
+ }
+
}
diff --git a/core/css/styles.css b/core/css/styles.css
index 66af01ae3c5..bfa15eb7e50 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -572,10 +572,15 @@ label.infield {
}
#body-login .update {
+ width: inherit;
text-align: center;
color: #ccc;
}
+#body-login .v-align {
+ width: inherit;
+}
+
#body-login .update img.float-spinner {
float: left;
}
diff --git a/lib/private/files/objectstore/homeobjectstorestorage.php b/lib/private/files/objectstore/homeobjectstorestorage.php
index 26a2788d860..947fc496b20 100644
--- a/lib/private/files/objectstore/homeobjectstorestorage.php
+++ b/lib/private/files/objectstore/homeobjectstorestorage.php
@@ -22,7 +22,7 @@ namespace OC\Files\ObjectStore;
use OC\User\User;
-class HomeObjectStoreStorage extends ObjectStoreStorage {
+class HomeObjectStoreStorage extends ObjectStoreStorage implements \OCP\Files\IHomeStorage {
/**
* The home user storage requires a user object to create a unique storage id
diff --git a/lib/private/files/storage/home.php b/lib/private/files/storage/home.php
index 214deede620..015b1f01885 100644
--- a/lib/private/files/storage/home.php
+++ b/lib/private/files/storage/home.php
@@ -11,7 +11,7 @@ namespace OC\Files\Storage;
/**
* Specialized version of Local storage for home directory usage
*/
-class Home extends Local {
+class Home extends Local implements \OCP\Files\IHomeStorage {
/**
* @var string
*/
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index ff3cb9ee68b..1a9b0e8d2ae 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -440,13 +440,17 @@ class View {
$internalPath1 = $mount->getInternalPath($absolutePath1 . $postFix1);
list(, $internalPath2) = Filesystem::resolvePath($absolutePath2 . $postFix2);
if ($internalPath1 === '' and $mount instanceof MoveableMount) {
- /**
- * @var \OC\Files\Mount\Mount | \OC\Files\Mount\MoveableMount $mount
- */
- $sourceMountPoint = $mount->getMountPoint();
- $result = $mount->moveMount($absolutePath2);
- $manager->moveMount($sourceMountPoint, $mount->getMountPoint());
- \OC_FileProxy::runPostProxies('rename', $absolutePath1, $absolutePath2);
+ if ($this->isTargetAllowed($absolutePath2)) {
+ /**
+ * @var \OC\Files\Mount\Mount | \OC\Files\Mount\MoveableMount $mount
+ */
+ $sourceMountPoint = $mount->getMountPoint();
+ $result = $mount->moveMount($absolutePath2);
+ $manager->moveMount($sourceMountPoint, $mount->getMountPoint());
+ \OC_FileProxy::runPostProxies('rename', $absolutePath1, $absolutePath2);
+ } else {
+ $result = false;
+ }
} elseif ($mp1 == $mp2) {
if ($storage1) {
$result = $storage1->rename($internalPath1, $internalPath2);
@@ -1185,4 +1189,27 @@ class View {
throw new \OCP\Files\InvalidPathException("Path length($pathLen) exceeds max path length($maxLen): $path");
}
}
+
+ /**
+ * check if it is allowed to move a mount point to a given target.
+ * It is not allowed to move a mount point into a different mount point
+ *
+ * @param string $target path
+ * @return boolean
+ */
+ private function isTargetAllowed($target) {
+
+ $result = false;
+
+ list($targetStorage,) = \OC\Files\Filesystem::resolvePath($target);
+ if ($targetStorage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
+ $result = true;
+ } else {
+ \OCP\Util::writeLog('files',
+ 'It is not allowed to move one mount point into another one',
+ \OCP\Util::DEBUG);
+ }
+
+ return $result;
+ }
}
diff --git a/lib/public/files/storage.php b/lib/public/files/storage.php
index 323d20db564..8f8d7852ee4 100644
--- a/lib/public/files/storage.php
+++ b/lib/public/files/storage.php
@@ -336,3 +336,7 @@ interface Storage {
*/
public function instanceOfStorage($class);
}
+
+interface IHomeStorage {
+
+}