summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-10-10 18:26:43 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-10-16 10:15:43 +0200
commit0254a3c406f2a945e2b01bbde3044d5a60751750 (patch)
tree9f2381ffc04cd8bf3fe5ed4fa56b772e25e122fa
parentc8d8578d1aac26373060e401cf50e734007c0b1c (diff)
downloadnextcloud-server-0254a3c406f2a945e2b01bbde3044d5a60751750.tar.gz
nextcloud-server-0254a3c406f2a945e2b01bbde3044d5a60751750.zip
make trashbin compatible with objectstore, replace glob with search in cache, make unknown free space work like unlimited free space
-rw-r--r--apps/files_trashbin/lib/trashbin.php18
-rw-r--r--lib/private/files/view.php10
2 files changed, 23 insertions, 5 deletions
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 120df345dda..73bb87955c7 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -745,6 +745,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);
}
@@ -911,24 +914,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 95f3e9a2c7f..3d3406af94e 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1110,6 +1110,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