]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/files.go
Refactor listener setup
[rbdr/mobius] / hotline / files.go
index e77f63129f1a5e574b4260aff4c8649e066bafc3..4f55eba13f29946a2cec4feed35040271e4276f2 100644 (file)
@@ -10,6 +10,8 @@ import (
        "strings"
 )
 
+const incompleteFileSuffix = ".incomplete"
+
 func downcaseFileExtension(filename string) string {
        splitStr := strings.Split(filename, ".")
        ext := strings.ToLower(
@@ -86,6 +88,10 @@ func getFileNameList(filePath string) (fields []Field, err error) {
                        copy(fnwi.Type[:], []byte("fldr")[:])
                        copy(fnwi.Creator[:], fileCreator[:])
                } else {
+                       // the Hotline protocol does not support file sizes > 4GiB due to the 4 byte field size, so skip them
+                       if file.Size() > 4294967296 {
+                               continue
+                       }
                        binary.BigEndian.PutUint32(fnwi.FileSize[:], uint32(file.Size()))
                        copy(fnwi.Type[:], []byte(fileTypeFromFilename(file.Name()).TypeCode)[:])
                        copy(fnwi.Creator[:], []byte(fileTypeFromFilename(file.Name()).CreatorCode)[:])
@@ -173,8 +179,6 @@ func EncodeFilePath(filePath string) []byte {
        return bytes
 }
 
-const incompleteFileSuffix = ".incomplete"
-
 // effectiveFile wraps os.Open to check for the presence of a partial file transfer as a fallback
 func effectiveFile(filePath string) (*os.File, error) {
        file, err := os.Open(filePath)