From e613c59dc37491e97d09601122fe2796e026c65c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 12 Apr 2018 15:10:05 +0200 Subject: [PATCH] * All apps: fixed moving attachments to new entries (without attachments) lost moved file --- api/src/Vfs/Links/StreamWrapper.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/api/src/Vfs/Links/StreamWrapper.php b/api/src/Vfs/Links/StreamWrapper.php index 5dd2ef8746..47e53cb914 100644 --- a/api/src/Vfs/Links/StreamWrapper.php +++ b/api/src/Vfs/Links/StreamWrapper.php @@ -397,6 +397,31 @@ class StreamWrapper extends LinksParent return is_null($time) ? true : parent::touch($url,$time,$atime); } + /** + * This method is called in response to rename() calls on URL paths associated with the wrapper. + * + * Reimplemented to create the entry directory, in case it's only faked to be there. + * + * @param string $path_from + * @param string $path_to + * @return boolean TRUE on success or FALSE on failure + */ + function rename ( $path_from, $path_to ) + { + if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path_from,$path_to)"); + + // Check to make sure target _really_ exists, not just fake dir from Links/StreamWrapper + $path = Vfs::parse_url($path_to, PHP_URL_PATH); + list(,/*$apps*/,/*$app*/,$id) = explode('/', $path); + + if($id && !parent::url_stat(Vfs::dirname($path_to),STREAM_URL_STAT_QUIET)) + { + $this->mkdir(Vfs::dirname($path), 0, STREAM_MKDIR_RECURSIVE ); + } + + return parent::rename($path_from,$path_to); + } + /** * Register this stream-wrapper */