]> git.r.bdr.sh - rbdr/mobius/commitdiff
Remove use of relative paths
authorJeff Halter <redacted>
Sat, 7 Aug 2021 16:45:46 +0000 (09:45 -0700)
committerJeff Halter <redacted>
Sat, 7 Aug 2021 16:45:46 +0000 (09:45 -0700)
hotline/server.go
hotline/transaction_handlers.go

index 0203dc9e67d4b02230ba58fb9739010d83fffaba..1429c62f47e2bbeb5011db6f4e18ba8f0959d8ba 100644 (file)
@@ -765,7 +765,7 @@ func (s *Server) TransferFile(conn net.Conn) error {
                i := 0
                _ = filepath.Walk(fullFilePath+"/", func(path string, info os.FileInfo, _ error) error {
                        i += 1
                i := 0
                _ = filepath.Walk(fullFilePath+"/", func(path string, info os.FileInfo, _ error) error {
                        i += 1
-                       subPath := path[basePathLen-2:]
+                       subPath := path[basePathLen:]
                        s.Logger.Infow("Sending fileheader", "i", i, "path", path, "fullFilePath", fullFilePath, "subPath", subPath, "IsDir", info.IsDir())
 
                        fileHeader := NewFileHeader(subPath, info.IsDir())
                        s.Logger.Infow("Sending fileheader", "i", i, "path", path, "fullFilePath", fullFilePath, "subPath", subPath, "IsDir", info.IsDir())
 
                        fileHeader := NewFileHeader(subPath, info.IsDir())
index ba90a56bcda94e2d3925d04b4d2b986de9b18fb8..5773d80375d5d871380f3501c355f28d1ab6e2ea 100644 (file)
@@ -472,9 +472,9 @@ func HandleDeleteFile(cc *ClientConn, t *Transaction) (res []Transaction, err er
        fileName := string(t.GetField(fieldFileName).Data)
        filePath := cc.Server.Config.FileRoot + ReadFilePath(t.GetField(fieldFilePath).Data)
 
        fileName := string(t.GetField(fieldFileName).Data)
        filePath := cc.Server.Config.FileRoot + ReadFilePath(t.GetField(fieldFilePath).Data)
 
-       path := "./" + filePath + "/" + fileName
+       path := filePath + fileName
 
 
-       cc.Server.Logger.Debugw("Delete file", "src", filePath+"/"+fileName)
+       cc.Server.Logger.Debugw("Delete file", "src", path)
 
        fi, err := os.Stat(path)
        if err != nil {
 
        fi, err := os.Stat(path)
        if err != nil {
@@ -505,8 +505,8 @@ func HandleDeleteFile(cc *ClientConn, t *Transaction) (res []Transaction, err er
 // HandleMoveFile moves files or folders. Note: seemingly not documented
 func HandleMoveFile(cc *ClientConn, t *Transaction) (res []Transaction, err error) {
        fileName := string(t.GetField(fieldFileName).Data)
 // HandleMoveFile moves files or folders. Note: seemingly not documented
 func HandleMoveFile(cc *ClientConn, t *Transaction) (res []Transaction, err error) {
        fileName := string(t.GetField(fieldFileName).Data)
-       filePath := "./" + cc.Server.Config.FileRoot + ReadFilePath(t.GetField(fieldFilePath).Data)
-       fileNewPath := "./" + cc.Server.Config.FileRoot + ReadFilePath(t.GetField(fieldFileNewPath).Data)
+       filePath :=  cc.Server.Config.FileRoot + ReadFilePath(t.GetField(fieldFilePath).Data)
+       fileNewPath :=  cc.Server.Config.FileRoot + ReadFilePath(t.GetField(fieldFileNewPath).Data)
 
        cc.Server.Logger.Debugw("Move file", "src", filePath+"/"+fileName, "dst", fileNewPath+"/"+fileName)
 
 
        cc.Server.Logger.Debugw("Move file", "src", filePath+"/"+fileName, "dst", fileNewPath+"/"+fileName)
 
@@ -1241,7 +1241,7 @@ func HandleDownloadFolder(cc *ClientConn, t *Transaction) (res []Transaction, er
 
        fp := NewFilePath(t.GetField(fieldFilePath).Data)
 
 
        fp := NewFilePath(t.GetField(fieldFilePath).Data)
 
-       fullFilePath := fmt.Sprintf("./%v/%v", cc.Server.Config.FileRoot+fp.String(), string(fileTransfer.FileName))
+       fullFilePath := fmt.Sprintf("%v%v", cc.Server.Config.FileRoot+fp.String(), string(fileTransfer.FileName))
        transferSize, err := CalcTotalSize(fullFilePath)
        if err != nil {
                return res, err
        transferSize, err := CalcTotalSize(fullFilePath)
        if err != nil {
                return res, err