diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2025-07-06 16:02:53 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2025-07-06 16:02:53 -0700 |
| commit | e61b3160bc8936b7ffb0af5c89b13742a7081826 (patch) | |
| tree | db3ba0e6cf0add99da6fa806709670d4b39d4bbf /hotline/file_transfer.go | |
| parent | c0ec79dcfd267f7495274a9186b36a1b0669f000 (diff) | |
Add ForkType type alias for improved type safety
- Replace [4]byte with ForkType in ForkInfoList struct
- Update constants ForkTypeDATA and ForkTypeMACR to use ForkType
- Add String() method to ForkType for better debugging
- Improve consistency with existing type patterns (FieldType, TranType)
- Clean up unused code and improve documentation
Diffstat (limited to 'hotline/file_transfer.go')
| -rw-r--r-- | hotline/file_transfer.go | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/hotline/file_transfer.go b/hotline/file_transfer.go index 701259a..521b963 100644 --- a/hotline/file_transfer.go +++ b/hotline/file_transfer.go @@ -172,23 +172,6 @@ type folderUpload struct { FileNamePath []byte } -//func (fu *folderUpload) Write(p []byte) (int, error) { -// if len(p) < 7 { -// return 0, errors.New("buflen too short") -// } -// copy(fu.DataSize[:], p[0:2]) -// copy(fu.IsFolder[:], p[2:4]) -// copy(fu.PathItemCount[:], p[4:6]) -// -// fu.FileNamePath = make([]byte, binary.BigEndian.Uint16(fu.DataSize[:])-4) // -4 to subtract the path separator bytes TODO: wat -// n, err := io.ReadFull(rwc, fu.FileNamePath) -// if err != nil { -// return 0, err -// } -// -// return n + 6, nil -//} - // pathSegmentScanner implements bufio.SplitFunc for parsing path segments func pathSegmentScanner(data []byte, _ bool) (advance int, token []byte, err error) { if len(data) < 3 { @@ -269,12 +252,6 @@ func (fh *FileHeader) Read(p []byte) (int, error) { } func DownloadHandler(w io.Writer, fullPath string, fileTransfer *FileTransfer, fs FileStore, rLogger *slog.Logger, preserveForks bool) error { - //s.Stats.DownloadCounter += 1 - //s.Stats.DownloadsInProgress += 1 - //defer func() { - // s.Stats.DownloadsInProgress -= 1 - //}() - var dataOffset int64 if fileTransfer.FileResumeData != nil { dataOffset = int64(binary.BigEndian.Uint32(fileTransfer.FileResumeData.ForkInfoList[0].DataSize[:])) @@ -520,7 +497,6 @@ func DownloadFolderHandler(rwc io.ReadWriter, fullPath string, fileTransfer *Fil return fmt.Errorf("error opening file: %w", err) } - // wr := bufio.NewWriterSize(rwc, 1460) if _, err = io.Copy(rwc, io.TeeReader(file, fileTransfer.bytesSentCounter)); err != nil { return fmt.Errorf("error sending file: %w", err) } @@ -576,7 +552,6 @@ func UploadFolderHandler(rwc io.ReadWriter, fullPath string, fileTransfer *FileT //s.Stats.UploadCounter += 1 var fu folderUpload - // TODO: implement io.Writer on folderUpload and replace this if _, err := io.ReadFull(rwc, fu.DataSize[:]); err != nil { return err } @@ -586,7 +561,7 @@ func UploadFolderHandler(rwc io.ReadWriter, fullPath string, fileTransfer *FileT if _, err := io.ReadFull(rwc, fu.PathItemCount[:]); err != nil { return err } - fu.FileNamePath = make([]byte, binary.BigEndian.Uint16(fu.DataSize[:])-4) // -4 to subtract the path separator bytes TODO: wat + fu.FileNamePath = make([]byte, binary.BigEndian.Uint16(fu.DataSize[:])-4) // -4 to subtract the length of the DataSize and IsFolder fields if _, err := io.ReadFull(rwc, fu.FileNamePath); err != nil { return err } |