diff --git a/pkg/proc/interaction.go b/pkg/proc/interaction.go index adb6968..252070e 100644 --- a/pkg/proc/interaction.go +++ b/pkg/proc/interaction.go @@ -28,14 +28,6 @@ func ProcessPutExtended( var w io.WriteCloser r, w := io.Pipe() - err := s.PutFileToDest(name, r, settings) - - if err != nil { - _ = ycl.ReplyError(err, "failed to upload") - - return err - } - defer r.Close() defer w.Close() @@ -103,6 +95,15 @@ func ProcessPutExtended( } }() + /* Should go after reader dispatch! */ + err := s.PutFileToDest(name, r, settings) + + if err != nil { + _ = ycl.ReplyError(err, "failed to upload") + + return err + } + wg.Wait() _, err = ycl.GetRW().Write(message.NewReadyForQueryMessage().Encode())