From: Jeff Halter Date: Tue, 21 Jun 2022 16:18:56 +0000 (-0700) Subject: Fix some Windows compatibility issues X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/commitdiff_plain/e00ff8fe2e1b878abfa3d1bfd12449d5f2bb5f59?ds=inline Fix some Windows compatibility issues --- diff --git a/hotline/file_path.go b/hotline/file_path.go index c8fe652..c7e1574 100644 --- a/hotline/file_path.go +++ b/hotline/file_path.go @@ -94,7 +94,6 @@ func readPath(fileRoot string, filePath, fileName []byte) (fullPath string, err } fullPath = filepath.Join( - "/", fileRoot, fp.String(), filepath.Join("/", string(fileName)), diff --git a/hotline/server.go b/hotline/server.go index 9ffd272..ba0a668 100644 --- a/hotline/server.go +++ b/hotline/server.go @@ -808,8 +808,6 @@ func (s *Server) handleFileTransfer(ctx context.Context, rwc io.ReadWriter) erro return err } - defer func() { _ = file.Close() }() - s.Logger.Infow("File upload started", "transactionRef", fileTransfer.ReferenceNumber, "dstFile", destinationFile) rForkWriter := io.Discard @@ -830,6 +828,10 @@ func (s *Server) handleFileTransfer(ctx context.Context, rwc io.ReadWriter) erro return err } + if err := file.Close(); err != nil { + return err + } + if err := s.FS.Rename(destinationFile+".incomplete", destinationFile); err != nil { return err } diff --git a/hotline/transaction_handlers.go b/hotline/transaction_handlers.go index c3b8c59..f080047 100644 --- a/hotline/transaction_handlers.go +++ b/hotline/transaction_handlers.go @@ -5,6 +5,7 @@ import ( "encoding/binary" "errors" "fmt" + "github.com/davecgh/go-spew/spew" "gopkg.in/yaml.v3" "io/ioutil" "math/big" @@ -1658,6 +1659,8 @@ func HandleGetFileNameList(cc *ClientConn, t *Transaction) (res []Transaction, e return res, err } + spew.Dump(fullPath) + var fp FilePath if t.GetField(fieldFilePath).Data != nil { if err = fp.UnmarshalBinary(t.GetField(fieldFilePath).Data); err != nil {