make trashbin compatible with objectstore, replace glob with search in cache, make unknown free space work like unlimited free space
This commit is contained in:
parent
c8d8578d1a
commit
0254a3c406
2 changed files with 23 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -1109,6 +1109,16 @@ class View {
|
|||
return $this->searchCommon('%' . $query . '%', 'search');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue