Forráskód Böngészése

Fixed webdav path joining bug for folder upload

tobychui 3 éve
szülő
commit
9c1b373c3f
2 módosított fájl, 10 hozzáadás és 7 törlés
  1. 2 2
      file_system.go
  2. 8 5
      mod/storage/ftp/aofs.go

+ 2 - 2
file_system.go

@@ -797,8 +797,8 @@ func system_fs_handleUpload(w http.ResponseWriter, r *http.Request) {
 		}
 	}
 
-	destFilepath := filepath.ToSlash(filepath.Clean(realUploadPath)) + "/" + storeFilename
-
+	destFilepath := arozfs.ToSlash(filepath.Join(realUploadPath, storeFilename))
+	//fmt.Println(destFilepath, realUploadPath, storeFilename)
 	if !targetFs.FileExists(filepath.Dir(destFilepath)) {
 		targetFs.MkdirAll(filepath.Dir(destFilepath), 0775)
 	}

+ 8 - 5
mod/storage/ftp/aofs.go

@@ -166,12 +166,13 @@ func (a aofs) Rename(oldname, newname string) error {
 		if err != nil {
 			return err
 		}
+		defer f.Close()
 
 		err = fshdest.FileSystemAbstraction.WriteStream(rewritePathdest, f, 0775)
 		if err != nil {
 			return err
 		}
-		f.Close()
+
 		err = fshsrc.FileSystemAbstraction.RemoveAll(rewritePathsrc)
 		if err != nil {
 			return err
@@ -246,10 +247,12 @@ func (a aofs) pathRewrite(path string) (*filesystem.FileSystemHandler, string, e
 			return nil, "", errors.New("File System Abstraction not found")
 		}
 
-		if fsh.RequireBuffer {
-			//Not supported
-			return nil, "", errors.New("Buffered file system not supported by FTP driver")
-		}
+		/*
+			if fsh.RequireBuffer {
+				//Not supported
+				return nil, "", errors.New("Buffered file system not supported by FTP driver")
+			}
+		*/
 
 		rpath, err := fsh.FileSystemAbstraction.VirtualPathToRealPath(fsh.UUID+":/"+strings.Join(remainingPaths, "/"), a.userinfo.Username)
 		if err != nil {