From 50759607e4a94c63ae02bf6302acd191913bc834 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sat, 16 Feb 2013 17:42:06 -0500 Subject: [PATCH 1/3] add file_exists method to files_trashbin app --- apps/files_trashbin/lib/trash.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index d88dc1ac252..8cb44d0a684 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -246,8 +246,19 @@ class Trashbin { return $size; } - - + + /** + * check to see whether a file exists in trashbin + * @param $file path to the file to check + * @return true if file exists, otherwise false + */ + public static function file_exists($file) { + $user = \OCP\User::getUser(); + $view = new \OC_FilesystemView('/'.$user); + $target = \OC_Filesystem::normalizePath('files_trashbin/'.$file); + return $view->file_exists($target); + } + /** * clean up the trash bin * @param max. available disk space for trashbin From 4b4b1f86925248a36c4cc62e91905e605b891e70 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sat, 16 Feb 2013 17:44:51 -0500 Subject: [PATCH 2/3] Properly delete empty directories in Trashbin Instead of checking delted file size, we do a real check. this fixes #1688 --- apps/files_trashbin/ajax/delete.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index 7a6bd1342ea..f41482bef55 100644 --- a/apps/files_trashbin/ajax/delete.php +++ b/apps/files_trashbin/ajax/delete.php @@ -15,7 +15,9 @@ if ($path_parts['dirname'] == '.') { $timestamp = null; } -if (OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp)) { +OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp); + +if (!OCA\Files_Trashbin\Trashbin::file_exists($filename)) { OCP\JSON::success(array("data" => array("filename" => $file))); } else { $l = OC_L10N::get('files_trashbin'); From c0ac98066e717ac8dba98df5bbfe881c9b344495 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Mon, 18 Feb 2013 09:49:50 -0500 Subject: [PATCH 3/3] check filename and timestamp in Trashbin's file_exists method --- apps/files_trashbin/lib/trash.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 8cb44d0a684..a948b47e0ad 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -249,13 +249,21 @@ class Trashbin { /** * check to see whether a file exists in trashbin - * @param $file path to the file to check + * @param $filename path to the file + * @param $timestamp of deletion time * @return true if file exists, otherwise false */ - public static function file_exists($file) { + public static function file_exists($filename, $timestamp=null) { $user = \OCP\User::getUser(); $view = new \OC_FilesystemView('/'.$user); - $target = \OC_Filesystem::normalizePath('files_trashbin/'.$file); + + if ($timestamp) { + $filename = $filename.'.d'.$timestamp; + } else { + $filename = $filename; + } + + $target = \OC_Filesystem::normalizePath('files_trashbin/'.$filename); return $view->file_exists($target); }