Avoid filepath.Dir as it returns paths with back slashes on Windows

This commit is contained in:
Gilbert Chen
2018-06-07 16:00:39 -04:00
parent 7e021f26d3
commit 9ae306644d

View File

@@ -18,7 +18,6 @@ import (
"math/rand" "math/rand"
"net/http" "net/http"
//"net/http/httputil" //"net/http/httputil"
"path/filepath"
"strconv" "strconv"
"sync" "sync"
"time" "time"
@@ -360,11 +359,12 @@ func (storage *WebDAVStorage) MoveFile(threadIndex int, from string, to string)
// createParentDirectory creates the parent directory if it doesn't exist in the cache // createParentDirectory creates the parent directory if it doesn't exist in the cache
func (storage *WebDAVStorage) createParentDirectory(threadIndex int, dir string) (err error) { func (storage *WebDAVStorage) createParentDirectory(threadIndex int, dir string) (err error) {
parent := filepath.Dir(dir)
if parent == "." { found := strings.LastIndex(dir, "/")
if found == -1 {
return nil return nil
} }
parent := dir[:found]
storage.directoryCacheLock.Lock() storage.directoryCacheLock.Lock()
_, exist := storage.directoryCache[parent] _, exist := storage.directoryCache[parent]