[Pkg-owncloud-commits] [owncloud] 02/34: make trashbin compatible with objectstore, replace glob with search in cache, make unknown free space work like unlimited free space

David Prévot taffit at moszumanska.debian.org
Fri Oct 17 01:32:15 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 3ce828b4b7050a076065b0b33a8904d16d533f0a
Author: Jörn Friedrich Dreyer <jfd at butonic.de>
Date:   Fri Oct 10 18:26:43 2014 +0200

    make trashbin compatible with objectstore, replace glob with search in cache, make unknown free space work like unlimited free space
---
 apps/files_trashbin/lib/trashbin.php | 18 +++++++++++++-----
 lib/private/files/view.php           | 10 ++++++++++
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 121f8f7..e97bf25 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -708,6 +708,9 @@ class Trashbin {
 		if ($quota === null || $quota === 'none') {
 			$quota = \OC\Files\Filesystem::free_space('/');
 			$softQuota = false;
+			if ($quota === \OC\Files\SPACE_UNKNOWN) {
+				$quota = 0;
+			}
 		} else {
 			$quota = \OCP\Util::computerFileSize($quota);
 		}
@@ -874,24 +877,29 @@ class Trashbin {
 	 *
 	 * @param string $filename name of the file which should be restored
 	 * @param int $timestamp timestamp when the file was deleted
+	 * @return array
 	 */
 	private static function getVersionsFromTrash($filename, $timestamp) {
 		$view = new \OC\Files\View('/' . \OCP\User::getUser() . '/files_trashbin/versions');
-		$versionsName = $view->getLocalFile($filename) . '.v';
-		$escapedVersionsName = preg_replace('/(\*|\?|\[)/', '[$1]', $versionsName);
 		$versions = array();
+
+		//force rescan of versions, local storage may not have updated the cache
+		/** @var \OC\Files\Storage\Storage $storage */
+		list($storage, ) = $view->resolvePath('/');
+		$storage->getScanner()->scan('');
+
 		if ($timestamp) {
 			// fetch for old versions
-			$matches = glob($escapedVersionsName . '*.d' . $timestamp);
+			$matches = $view->searchRaw($filename . '.v%.d' . $timestamp);
 			$offset = -strlen($timestamp) - 2;
 		} else {
-			$matches = glob($escapedVersionsName . '*');
+			$matches = $view->searchRaw($filename . '.v%');
 		}
 
 		if (is_array($matches)) {
 			foreach ($matches as $ma) {
 				if ($timestamp) {
-					$parts = explode('.v', substr($ma, 0, $offset));
+					$parts = explode('.v', substr($ma['path'], 0, $offset));
 					$versions[] = (end($parts));
 				} else {
 					$parts = explode('.v', $ma);
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index baf765d..9b85560 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1092,6 +1092,16 @@ class View {
 	}
 
 	/**
+	 * search for files with the name matching $query
+	 *
+	 * @param string $query
+	 * @return FileInfo[]
+	 */
+	public function searchRaw($query) {
+		return $this->searchCommon($query, 'search');
+	}
+
+	/**
 	 * search for files by mimetype
 	 *
 	 * @param string $mimetype

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list