diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-01-26 12:22:22 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-01-26 12:22:22 +0100 |
commit | 02b9bad81b51a37dd60cab34b80796c79390c426 (patch) | |
tree | 2021e5f7b51d3708e73cf0ce612069c6fc215bf9 /apps/files_trashbin/lib/storage.php | |
parent | a1cc9eea56a39646e679fd42b6a33249f9aad170 (diff) | |
download | nextcloud-server-02b9bad81b51a37dd60cab34b80796c79390c426.tar.gz nextcloud-server-02b9bad81b51a37dd60cab34b80796c79390c426.zip |
Fix bogus deletion on copy + unlink through rename
Cross-storage rename would cause copy + unlink. That unlink operation
must not trigger the trashbin.
Diffstat (limited to 'apps/files_trashbin/lib/storage.php')
-rw-r--r-- | apps/files_trashbin/lib/storage.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/apps/files_trashbin/lib/storage.php b/apps/files_trashbin/lib/storage.php index f51d2a2fb70..21b4e56d0bb 100644 --- a/apps/files_trashbin/lib/storage.php +++ b/apps/files_trashbin/lib/storage.php @@ -33,12 +33,43 @@ class Storage extends Wrapper { // move files across storages private $deletedFiles = array(); + /** + * Disable trash logic + * + * @var bool + */ + private static $disableTrash = false; + function __construct($parameters) { $this->mountPoint = $parameters['mountPoint']; parent::__construct($parameters); } + /** + * @internal + */ + public static function preRenameHook($params) { + // in cross-storage cases, a rename is a copy + unlink, + // that last unlink must not go to trash + self::$disableTrash = true; + } + + /** + * @internal + */ + public static function postRenameHook($params) { + self::$disableTrash = false; + } + + /** + * Deletes the given file by moving it into the trashbin. + * + * @param string $path + */ public function unlink($path) { + if (self::$disableTrash) { + return $this->storage->unlink($path); + } $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path); $result = true; if (!isset($this->deletedFiles[$normalized])) { |