From e00ff8fe2e1b878abfa3d1bfd12449d5f2bb5f59 Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Tue, 21 Jun 2022 09:18:56 -0700 Subject: Fix some Windows compatibility issues --- hotline/file_path.go | 1 - hotline/server.go | 6 ++++-- hotline/transaction_handlers.go | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) 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 { -- cgit