lib/file: improve error message when attempting to create dir on nonexistent drive on windows

This replaces built-in os.MkdirAll with a patched version that stops the recursion
when reaching the volume part of the path. The original version would continue recursion,
and for extended length paths end up with \\? as the top-level directory, and the error
message would then be something like:
mkdir \\?: The filename, directory name, or volume label syntax is incorrect.
This commit is contained in:
albertony 2021-06-11 00:46:36 +02:00
parent b30731c9d0
commit fbc7f2e61b
21 changed files with 261 additions and 27 deletions

View file

@ -8,6 +8,8 @@ import (
"net"
"os"
"path/filepath"
"github.com/rclone/rclone/lib/file"
)
func newUnixListener(path string, gid int) (net.Listener, string, error) {
@ -31,7 +33,7 @@ func newUnixListener(path string, gid int) (net.Listener, string, error) {
path = filepath.Join(sockDir, path)
}
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
if err := file.MkdirAll(filepath.Dir(path), 0755); err != nil {
return nil, "", err
}
if err := os.Remove(path); err != nil && !os.IsNotExist(err) {