summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_trashbin/appinfo/app.php2
-rw-r--r--apps/files_trashbin/lib/exceptions.php26
-rw-r--r--apps/files_trashbin/lib/trashbin.php24
3 files changed, 46 insertions, 6 deletions
diff --git a/apps/files_trashbin/appinfo/app.php b/apps/files_trashbin/appinfo/app.php
index 383115b8e63..718c2f45a34 100644
--- a/apps/files_trashbin/appinfo/app.php
+++ b/apps/files_trashbin/appinfo/app.php
@@ -1,6 +1,8 @@
<?php
$l = OC_L10N::get('files_trashbin');
+OC::$CLASSPATH['OCA\Files_Trashbin\Exceptions\CopyRecursiveException'] = 'files_trashbin/lib/exceptions.php';
+
// register hooks
\OCA\Files_Trashbin\Trashbin::registerHooks();
diff --git a/apps/files_trashbin/lib/exceptions.php b/apps/files_trashbin/lib/exceptions.php
new file mode 100644
index 00000000000..23e50293b77
--- /dev/null
+++ b/apps/files_trashbin/lib/exceptions.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * ownCloud - trash bin
+ *
+ * @author Bjoern Schiessle
+ * @copyright 2014 Bjoern Schiessle schiessle@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Files_Trashbin\Exceptions;
+
+class CopyRecursiveException extends \Exception {
+}
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 522f7d4b7e3..ee3969323cf 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -117,10 +117,18 @@ class Trashbin {
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
$trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp;
- $sizeOfAddedFiles = self::copy_recursive('/files/' . $file_path, $trashPath, $view);
+ try {
+ $sizeOfAddedFiles = self::copy_recursive('/files/'.$file_path, $trashPath, $view);
+ } catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
+ $sizeOfAddedFiles = false;
+ if ($view->file_exists($trashPath)) {
+ $view->deleteAll($trashPath);
+ }
+ \OC_Log::write('files_trashbin', 'Couldn\'t move ' . $file_path . ' to the trash bin', \OC_log::ERROR);
+ }
\OC_FileProxy::$enabled = $proxyStatus;
- if ($view->file_exists('files_trashbin/files/' . $filename . '.d' . $timestamp)) {
+ if ($sizeOfAddedFiles !== false) {
$size = $sizeOfAddedFiles;
$query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");
$result = $query->execute(array($filename, $timestamp, $location, $user));
@@ -137,8 +145,6 @@ class Trashbin {
if ($user !== $owner) {
self::copyFilesToOwner($file_path, $owner, $ownerPath, $timestamp);
}
- } else {
- \OC_Log::write('files_trashbin', 'Couldn\'t move ' . $file_path . ' to the trash bin', \OC_log::ERROR);
}
$userTrashSize += $size;
@@ -823,13 +829,19 @@ class Trashbin {
$size += self::copy_recursive($pathDir, $destination . '/' . $i['name'], $view);
} else {
$size += $view->filesize($pathDir);
- $view->copy($pathDir, $destination . '/' . $i['name']);
+ $result = $view->copy($pathDir, $destination . '/' . $i['name']);
+ if (!$result) {
+ throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
+ }
$view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir));
}
}
} else {
$size += $view->filesize($source);
- $view->copy($source, $destination);
+ $result = $view->copy($source, $destination);
+ if (!$result) {
+ throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
+ }
$view->touch($destination, $view->filemtime($source));
}
return $size;