diff options
author | Vincent Petry <pvince81@owncloud.com> | 2013-11-26 06:42:36 -0800 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2013-11-26 06:42:36 -0800 |
commit | 2653d914d96e40541378d40c0e6c7589c789f401 (patch) | |
tree | 09a0c68c38324f90a513951ae5ad157d8e7a4e2c /apps | |
parent | dbd8128c0717941791a48334e0dcd8fec02d1e4a (diff) | |
parent | c3e34676ba0a5467cadc1fd931ed659262705388 (diff) | |
download | nextcloud-server-2653d914d96e40541378d40c0e6c7589c789f401.tar.gz nextcloud-server-2653d914d96e40541378d40c0e6c7589c789f401.zip |
Merge pull request #6008 from owncloud/extstorage-smb-webdav-renamefix
Fixed SMB rename function to overwrite target file
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/3rdparty/smb4php/smb.php | 16 | ||||
-rw-r--r-- | apps/files_external/lib/streamwrapper.php | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/apps/files_external/3rdparty/smb4php/smb.php b/apps/files_external/3rdparty/smb4php/smb.php index 9650f809041..87638271f0e 100644 --- a/apps/files_external/3rdparty/smb4php/smb.php +++ b/apps/files_external/3rdparty/smb4php/smb.php @@ -302,6 +302,7 @@ class smb { } function rename ($url_from, $url_to) { + $replace = false; list ($from, $to) = array (smb::parse_url($url_from), smb::parse_url($url_to)); if ($from['host'] <> $to['host'] || $from['share'] <> $to['share'] || @@ -314,7 +315,20 @@ class smb { trigger_error('rename(): error in URL', E_USER_ERROR); } smb::clearstatcache ($url_from); - $result = smb::execute ('rename "'.$from['path'].'" "'.$to['path'].'"', $to); + $cmd = ''; + // check if target file exists + if (smb::url_stat($url_to)) { + // delete target file first + $cmd = 'del "' . $to['path'] . '"; '; + $replace = true; + } + $cmd .= 'rename "' . $from['path'] . '" "' . $to['path'] . '"'; + $result = smb::execute($cmd, $to); + if ($replace) { + // clear again, else the cache will return the info + // from the old file + smb::clearstatcache ($url_to); + } return $result !== false; } diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index aa42cbde828..7a1991d4f04 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -38,7 +38,7 @@ abstract class StreamWrapper extends Common { } public function filetype($path) { - return filetype($this->constructUrl($path)); + return @filetype($this->constructUrl($path)); } public function file_exists($path) { |