* All apps: fixed moving attachments to new entries (without attachments) lost moved file

This commit is contained in:
Ralf Becker 2018-04-12 15:10:05 +02:00
parent 3937c9f2b6
commit 81143a0624

View File

@ -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
*/