]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/file_transfer.go
Wrap file transfer errors with more context
[rbdr/mobius] / hotline / file_transfer.go
index 12725db620779d7ba4e1f197ba2683c960986dc7..b11aeae585c89c7905921a474cd6ed2e3f789ce8 100644 (file)
@@ -326,12 +326,14 @@ func UploadHandler(rwc io.ReadWriter, fullPath string, fileTransfer *FileTransfe
                }
        }
 
+       defer file.Close()
+
        f, err := NewFileWrapper(fileStore, fullPath, 0)
        if err != nil {
                return err
        }
 
-       rLogger.Info("File upload started", "dstFile", fullPath)
+       rLogger.Debug("File upload started", "dstFile", fullPath)
 
        rForkWriter := io.Discard
        iForkWriter := io.Discard
@@ -348,15 +350,11 @@ func UploadHandler(rwc io.ReadWriter, fullPath string, fileTransfer *FileTransfe
        }
 
        if err := receiveFile(rwc, file, rForkWriter, iForkWriter, fileTransfer.bytesSentCounter); err != nil {
-               rLogger.Error(err.Error())
-       }
-
-       if err := file.Close(); err != nil {
-               return err
+               return fmt.Errorf("receive file: %v", err)
        }
 
        if err := fileStore.Rename(fullPath+".incomplete", fullPath); err != nil {
-               return err
+               return fmt.Errorf("rename incomplete file: %v", err)
        }
 
        rLogger.Info("File upload complete", "dstFile", fullPath)
@@ -421,7 +419,6 @@ func DownloadFolderHandler(rwc io.ReadWriter, fullPath string, fileTransfer *Fil
                }
 
                subPath := path[basePathLen+1:]
-               rLogger.Debug("Sending fileheader", "i", i, "path", path, "fullFilePath", fullPath, "subPath", subPath, "IsDir", info.IsDir())
 
                if i == 1 {
                        return nil
@@ -437,8 +434,6 @@ func DownloadFolderHandler(rwc io.ReadWriter, fullPath string, fileTransfer *Fil
                        return err
                }
 
-               rLogger.Debug("Client folder download action", "action", fmt.Sprintf("%X", nextAction[0:2]))
-
                var dataOffset int64
 
                switch nextAction[1] {