From: Jeff Halter Date: Sat, 7 Aug 2021 16:45:46 +0000 (-0700) Subject: Remove use of relative paths X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/commitdiff_plain/f6d08d0ad9198b4d5a9ee5fcf108015f927fd657 Remove use of relative paths --- diff --git a/hotline/server.go b/hotline/server.go index 0203dc9..1429c62 100644 --- a/hotline/server.go +++ b/hotline/server.go @@ -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 - 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()) diff --git a/hotline/transaction_handlers.go b/hotline/transaction_handlers.go index ba90a56..5773d80 100644 --- a/hotline/transaction_handlers.go +++ b/hotline/transaction_handlers.go @@ -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) - 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 { @@ -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) - 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) @@ -1241,7 +1241,7 @@ func HandleDownloadFolder(cc *ClientConn, t *Transaction) (res []Transaction, er 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