From 42ea57c124f42f0c95c1c6c9277a81dc1568a55e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 7 Dec 2017 17:16:46 +0800 Subject: [PATCH] * All apps/PostgreSQL: fix SQL error when deleting an entry without attachments --- api/src/Vfs/Links/StreamWrapper.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/api/src/Vfs/Links/StreamWrapper.php b/api/src/Vfs/Links/StreamWrapper.php index ed9c9e166e..a1f59456b1 100644 --- a/api/src/Vfs/Links/StreamWrapper.php +++ b/api/src/Vfs/Links/StreamWrapper.php @@ -280,6 +280,30 @@ class StreamWrapper extends LinksParent return $ret; } + /** + * This method is called in response to rmdir() calls on URL paths associated with the wrapper. + * + * Reimplemented to do nothing (specially not complain), if an entry directory does not exist, + * as we always report them as existing! + * + * @param string $url + * @param int $options Possible values include STREAM_REPORT_ERRORS. + * @return boolean TRUE on success or FALSE on failure. + */ + function rmdir ( $url, $options ) + { + $path = $url != '/' ? Vfs::parse_url($url,PHP_URL_PATH) : $url; + + list(,/*$apps*/,/*$app*/,/*$id*/,$rest) = explode('/',$path); + + // never delete entry-dir, as it makes attic inaccessible + if (empty($rest)) + { + return true; + } + return parent::rmdir( $path, $options ); + } + /** * This method is called immediately after your stream object is created. *