diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-03-05 11:49:15 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-04-13 15:13:03 +0200 |
commit | 404773940daf9c5a686b92d65dd39fb44d766050 (patch) | |
tree | 06abfc6aff077788ffd034b987f362cf6b3c772f | |
parent | d26c6cab90b15bcf9cbd0d95015d8ad2405f7914 (diff) | |
download | nextcloud-server-404773940daf9c5a686b92d65dd39fb44d766050.tar.gz nextcloud-server-404773940daf9c5a686b92d65dd39fb44d766050.zip |
Detect storage full when doing cross storage copy/move
-rw-r--r-- | lib/private/files/storage/wrapper/quota.php | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/lib/private/files/storage/wrapper/quota.php b/lib/private/files/storage/wrapper/quota.php index 3c0fda98dad..92d749a814f 100644 --- a/lib/private/files/storage/wrapper/quota.php +++ b/lib/private/files/storage/wrapper/quota.php @@ -55,9 +55,14 @@ class Quota extends Wrapper { /** * @param string $path + * @param \OC\Files\Storage\Storage $storage */ - protected function getSize($path) { - $cache = $this->getCache(); + protected function getSize($path, $storage = null) { + if (is_null($storage)) { + $cache = $this->getCache(); + } else { + $cache = $storage->getCache(); + } $data = $cache->get($path); if (is_array($data) and isset($data['size'])) { return $data['size']; @@ -141,4 +146,34 @@ class Quota extends Wrapper { return $source; } } + + /** + * @param \OCP\Files\Storage $sourceStorage + * @param string $sourceInternalPath + * @param string $targetInternalPath + * @return bool + */ + public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) { + $free = $this->free_space(''); + if ($free < 0 or $this->getSize($sourceInternalPath, $sourceStorage) < $free) { + return $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + } else { + return false; + } + } + + /** + * @param \OCP\Files\Storage $sourceStorage + * @param string $sourceInternalPath + * @param string $targetInternalPath + * @return bool + */ + public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) { + $free = $this->free_space(''); + if ($free < 0 or $this->getSize($sourceInternalPath, $sourceStorage) < $free) { + return $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + } else { + return false; + } + } } |