aboutsummaryrefslogtreecommitdiff
path: root/hotline/file_transfer.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2025-06-26 14:01:22 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2025-06-26 14:01:22 -0700
commit55b8e77c409761639e95168c77dc22c13e858b6b (patch)
treebf2be552503c2674654f77adf9f5941c62d20668 /hotline/file_transfer.go
parent5ec29c573bde2417b5d8788966af2577332ce0fc (diff)
Replace filepath.Join with path.Join for Windows compatibility
Replace all instances of filepath.Join with path.Join across the codebase to improve Windows compatibility following the guidance from https://github.com/golang/go/issues/44305. Key changes: - Replaced filepath.Join with path.Join in 14 files - Updated import statements appropriately - Resolved variable shadowing issues where function parameters named 'path' were conflicting with the path package - Maintained filepath imports where needed for OS-specific functions like filepath.Walk, filepath.IsAbs, filepath.Dir, and filepath.Base All tests pass, confirming the changes maintain functionality while improving cross-platform compatibility.
Diffstat (limited to 'hotline/file_transfer.go')
-rw-r--r--hotline/file_transfer.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/hotline/file_transfer.go b/hotline/file_transfer.go
index f09e995..0ddac0b 100644
--- a/hotline/file_transfer.go
+++ b/hotline/file_transfer.go
@@ -11,6 +11,7 @@ import (
"log/slog"
"math"
"os"
+ "path"
"path/filepath"
"slices"
"strings"
@@ -200,7 +201,7 @@ func (fu *folderUpload) FormattedPath() string {
pathData = pathData[3+segLen:]
}
- return filepath.Join(pathSegments...)
+ return path.Join(pathSegments...)
}
type FileHeader struct {
@@ -566,8 +567,8 @@ func UploadFolderHandler(rwc io.ReadWriter, fullPath string, fileTransfer *FileT
}
if fu.IsFolder == [2]byte{0, 1} {
- if _, err := os.Stat(filepath.Join(fullPath, fu.FormattedPath())); os.IsNotExist(err) {
- if err := os.Mkdir(filepath.Join(fullPath, fu.FormattedPath()), 0777); err != nil {
+ if _, err := os.Stat(path.Join(fullPath, fu.FormattedPath())); os.IsNotExist(err) {
+ if err := os.Mkdir(path.Join(fullPath, fu.FormattedPath()), 0777); err != nil {
return err
}
}
@@ -580,7 +581,7 @@ func UploadFolderHandler(rwc io.ReadWriter, fullPath string, fileTransfer *FileT
nextAction := DlFldrActionSendFile
// Check if we have the full file already. If so, send dlFldrAction_NextFile to client to skip.
- _, err := os.Stat(filepath.Join(fullPath, fu.FormattedPath()))
+ _, err := os.Stat(path.Join(fullPath, fu.FormattedPath()))
if err != nil && !errors.Is(err, fs.ErrNotExist) {
return err
}
@@ -589,7 +590,7 @@ func UploadFolderHandler(rwc io.ReadWriter, fullPath string, fileTransfer *FileT
}
// Check if we have a partial file already. If so, send dlFldrAction_ResumeFile to client to resume upload.
- incompleteFile, err := os.Stat(filepath.Join(fullPath, fu.FormattedPath()+IncompleteFileSuffix))
+ incompleteFile, err := os.Stat(path.Join(fullPath, fu.FormattedPath()+IncompleteFileSuffix))
if err != nil && !errors.Is(err, fs.ErrNotExist) {
return err
}
@@ -642,7 +643,7 @@ func UploadFolderHandler(rwc io.ReadWriter, fullPath string, fileTransfer *FileT
return err
}
- filePath := filepath.Join(fullPath, fu.FormattedPath())
+ filePath := path.Join(fullPath, fu.FormattedPath())
hlFile, err := NewFileWrapper(fileStore, filePath, 0)
if err != nil {