Kaydet (Commit) 603b63b4 authored tarafından Mike Kaganski's avatar Mike Kaganski

tdf#121288: ReplaceFile WinAPI doesn't play nicely with WebDAV mapped drives

Change-Id: I0d7a64459de283dc10448e0086c66bedbf132553
Reviewed-on: https://gerrit.libreoffice.org/63133
Tested-by: Jenkins
Reviewed-by: 's avatarGabor Kelemen <kelemeng@ubuntu.com>
Tested-by: 's avatarGabor Kelemen <kelemeng@ubuntu.com>
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 21795eb3
...@@ -202,7 +202,7 @@ sal_uInt64 GetDefaultFileAttributes(const OUString& rURL) ...@@ -202,7 +202,7 @@ sal_uInt64 GetDefaultFileAttributes(const OUString& rURL)
} }
/// Determines if rURL is safe to move or not. /// Determines if rURL is safe to move or not.
bool IsFileMovable(const OUString& rURL) bool IsFileMovable(const INetURLObject& rURL)
{ {
#ifdef MACOSX #ifdef MACOSX
(void)rURL; (void)rURL;
...@@ -210,22 +210,25 @@ bool IsFileMovable(const OUString& rURL) ...@@ -210,22 +210,25 @@ bool IsFileMovable(const OUString& rURL)
return false; return false;
#else #else
if (!comphelper::isFileUrl(rURL)) if (rURL.GetProtocol() != INetProtocol::File)
// Not a file:// URL. // Not a file:// URL.
return false; return false;
#ifdef UNX #ifdef UNX
OUString rPath; OUString sPath = rURL.getFSysPath(FSysStyle::Unix);
if (osl::FileBase::getSystemPathFromFileURL(rURL, rPath) != osl::FileBase::E_None) if (sPath.isEmpty())
return false; return false;
struct stat buf; struct stat buf;
if (lstat(rPath.toUtf8().getStr(), &buf) != 0) if (lstat(sPath.toUtf8().getStr(), &buf) != 0)
return false; return false;
// Hardlink or symlink: osl::File::move() doesn't play with these nicely. // Hardlink or symlink: osl::File::move() doesn't play with these nicely.
if (buf.st_nlink > 1 || S_ISLNK(buf.st_mode)) if (buf.st_nlink > 1 || S_ISLNK(buf.st_mode))
return false; return false;
#elif defined _WIN32
if (tools::IsMappedWebDAVPath(rURL))
return false;
#endif #endif
return true; return true;
...@@ -1845,7 +1848,7 @@ void SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource, ...@@ -1845,7 +1848,7 @@ void SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource,
OUString aDestMainURL = aDest.GetMainURL(INetURLObject::DecodeMechanism::NONE); OUString aDestMainURL = aDest.GetMainURL(INetURLObject::DecodeMechanism::NONE);
sal_uInt64 nAttributes = GetDefaultFileAttributes(aDestMainURL); sal_uInt64 nAttributes = GetDefaultFileAttributes(aDestMainURL);
if (IsFileMovable(aDestMainURL) if (IsFileMovable(aDest)
&& osl::File::replace(aSourceMainURL, aDestMainURL) == osl::FileBase::E_None) && osl::File::replace(aSourceMainURL, aDestMainURL) == osl::FileBase::E_None)
{ {
if (nAttributes) if (nAttributes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment