X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/d7548c16cdbff6f9baa2f545eb808030a6b3ec2e..ba29c43bb23de83c7715271e0830cb9f00e9e1c1:/hotline/files.go diff --git a/hotline/files.go b/hotline/files.go index 04334e9..4f55eba 100644 --- a/hotline/files.go +++ b/hotline/files.go @@ -10,6 +10,8 @@ import ( "strings" ) +const incompleteFileSuffix = ".incomplete" + func downcaseFileExtension(filename string) string { splitStr := strings.Split(filename, ".") ext := strings.ToLower( @@ -56,6 +58,9 @@ func getFileNameList(filePath string) (fields []Field, err error) { } rFile, err := os.Stat(filePath + "/" + resolvedPath) + if errors.Is(err, os.ErrNotExist) { + continue + } if err != nil { return fields, err } @@ -83,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)[:]) @@ -170,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)