]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/files.go
Fix handling of symlinks in Files dir
[rbdr/mobius] / hotline / files.go
index 9c3efe2e182cc5ff45caa9c1c50e914d5c814f29..8d35a948da63caaa7ac5ef960b8def13eaf8cdb6 100644 (file)
@@ -50,13 +50,14 @@ func getFileNameList(path string, ignoreList []string) (fields []Field, err erro
                        return fields, err
                }
 
+               // Check if path is a symlink.  If so, follow it.
                if fileInfo.Mode()&os.ModeSymlink != 0 {
                        resolvedPath, err := os.Readlink(filepath.Join(path, file.Name()))
                        if err != nil {
                                return fields, err
                        }
 
-                       rFile, err := os.Stat(filepath.Join(path, resolvedPath))
+                       rFile, err := os.Stat(resolvedPath)
                        if errors.Is(err, os.ErrNotExist) {
                                continue
                        }
@@ -117,7 +118,11 @@ func getFileNameList(path string, ignoreList []string) (fields []Field, err erro
                        copy(fnwi.Creator[:], hlFile.ffo.FlatFileInformationFork.CreatorSignature)
                }
 
-               strippedName := strings.Replace(file.Name(), ".incomplete", "", -1)
+               strippedName := strings.ReplaceAll(file.Name(), ".incomplete", "")
+               strippedName, err = txtEncoder.String(strippedName)
+               if err != nil {
+                       return nil, err
+               }
 
                nameSize := make([]byte, 2)
                binary.BigEndian.PutUint16(nameSize, uint16(len(strippedName)))