]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/files.go
Exclude unsupported >4GiB files from file listings
[rbdr/mobius] / hotline / files.go
index 42e25db2aaec634fc3b905b081600f8c3f3f6504..d07f4455ebe188774a99164a5b033f55c141de7b 100644 (file)
@@ -56,6 +56,9 @@ func getFileNameList(filePath string) (fields []Field, err error) {
                        }
 
                        rFile, err := os.Stat(filePath + "/" + resolvedPath)
                        }
 
                        rFile, err := os.Stat(filePath + "/" + resolvedPath)
+                       if errors.Is(err, os.ErrNotExist) {
+                               continue
+                       }
                        if err != nil {
                                return fields, err
                        }
                        if err != nil {
                                return fields, err
                        }
@@ -83,6 +86,10 @@ func getFileNameList(filePath string) (fields []Field, err error) {
                        copy(fnwi.Type[:], []byte("fldr")[:])
                        copy(fnwi.Creator[:], fileCreator[:])
                } else {
                        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)[:])
                        binary.BigEndian.PutUint32(fnwi.FileSize[:], uint32(file.Size()))
                        copy(fnwi.Type[:], []byte(fileTypeFromFilename(file.Name()).TypeCode)[:])
                        copy(fnwi.Creator[:], []byte(fileTypeFromFilename(file.Name()).CreatorCode)[:])
@@ -180,7 +187,7 @@ func effectiveFile(filePath string) (*os.File, error) {
        }
 
        if errors.Is(err, fs.ErrNotExist) {
        }
 
        if errors.Is(err, fs.ErrNotExist) {
-               file, err = os.OpenFile(filePath+incompleteFileSuffix, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
+               file, err = os.OpenFile(filePath+incompleteFileSuffix, os.O_APPEND|os.O_WRONLY, 0644)
                if err != nil {
                        return nil, err
                }
                if err != nil {
                        return nil, err
                }