diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index 7a6bd1342ea278ea53d29f66d17ef4f31cd42ecf..f41482bef5553a2f303f39fcb4b32b638deab337 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'); diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index fbc3954c04096f0022a7cd2e455f84b0df091716..8d54a471b422ab719fa317a59cef6365d6e9bd68 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -246,8 +246,27 @@ class Trashbin { return $size; } - - + + /** + * check to see whether a file exists in trashbin + * @param $filename path to the file + * @param $timestamp of deletion time + * @return true if file exists, otherwise false + */ + public static function file_exists($filename, $timestamp=null) { + $user = \OCP\User::getUser(); + $view = new \OC_FilesystemView('/'.$user); + + if ($timestamp) { + $filename = $filename.'.d'.$timestamp; + } else { + $filename = $filename; + } + + $target = \OC_Filesystem::normalizePath('files_trashbin/'.$filename); + return $view->file_exists($target); + } + /** * clean up the trash bin * @param max. available disk space for trashbin