diff --git a/src/ioslaves/file/file.h b/src/ioslaves/file/file.h --- a/src/ioslaves/file/file.h +++ b/src/ioslaves/file/file.h @@ -110,6 +110,9 @@ // only during the brief period privileges are elevated. If it's not the case show // a warning and continue. PrivilegeOperationReturnValue tryChangeFileAttr(ActionType action, const QVariantList &args, int errcode); + + void redirect(const QUrl &url); + private: mutable QHash mUsercache; mutable QHash mGroupcache; diff --git a/src/ioslaves/file/file.cpp b/src/ioslaves/file/file.cpp --- a/src/ioslaves/file/file.cpp +++ b/src/ioslaves/file/file.cpp @@ -329,13 +329,29 @@ return; } +void FileProtocol::redirect(const QUrl &url) +{ + QUrl redir(url); + redir.setScheme(config()->readEntry("DefaultRemoteProtocol", "smb")); + + // if we would redirect into the Windows world, let's also check for the + // DavWWWRoot "token" which in the Windows world tells win explorer to access + // a webdav url + // https://www.webdavsystem.com/server/access/windows + if ((redir.scheme() == QLatin1String("smb")) && + redir.path().startsWith(QLatin1String("/DavWWWRoot/"))) { + redir.setPath(redir.path().mid(11)); // remove /DavWWWRoot + redir.setScheme(QLatin1String("webdav")); + } + + redirection(redir); + finished(); +} + void FileProtocol::get(const QUrl &url) { if (!url.isLocalFile()) { - QUrl redir(url); - redir.setScheme(config()->readEntry("DefaultRemoteProtocol", "smb")); - redirection(redir); - finished(); + redirect(url); return; } diff --git a/src/ioslaves/file/file_unix.cpp b/src/ioslaves/file/file_unix.cpp --- a/src/ioslaves/file/file_unix.cpp +++ b/src/ioslaves/file/file_unix.cpp @@ -802,11 +802,7 @@ void FileProtocol::stat(const QUrl &url) { if (!isLocalFileSameHost(url)) { - QUrl redir(url); - redir.setScheme(config()->readEntry("DefaultRemoteProtocol", "smb")); - redirection(redir); - // qDebug() << "redirecting to " << redir; - finished(); + redirect(url); return; } diff --git a/src/ioslaves/file/file_win.cpp b/src/ioslaves/file/file_win.cpp --- a/src/ioslaves/file/file_win.cpp +++ b/src/ioslaves/file/file_win.cpp @@ -355,11 +355,7 @@ void FileProtocol::stat(const QUrl &url) { if (!url.isLocalFile()) { - QUrl redir(url); - redir.setScheme(config()->readEntry("DefaultRemoteProtocol", "smb")); - redirection(redir); - // qDebug() << "redirecting to " << redir; - finished(); + redirect(url); return; }