Fix panic when library path has trailing path separator (#6619)

* Replace panic with warning if creating a folder hierarchy where parent is equal to current
* Clean stash paths so that comparison works correctly when creating folder hierarchies
This commit is contained in:
WithoutPants
2026-02-28 10:51:02 +11:00
committed by GitHub
parent 3b8f6bd94c
commit c7e1c3da69
2 changed files with 6 additions and 2 deletions

View File

@@ -42,7 +42,8 @@ func (s StashConfigs) GetStashFromDirPath(dirPath string) *StashConfig {
func (s StashConfigs) Paths() []string {
paths := make([]string, len(s))
for i, c := range s {
paths[i] = c.Path
// #6618 - clean the path to ensure comparison works correctly
paths[i] = filepath.Clean(c.Path)
}
return paths
}

View File

@@ -33,7 +33,10 @@ func GetOrCreateFolderHierarchy(ctx context.Context, fc models.FolderFinderCreat
// safety check - don't allow parent path to be the same as the current path,
// otherwise we could end up in an infinite loop
if parentPath == path {
panic(fmt.Sprintf("parent path is the same as the current path: %s", path))
// #6618 - log a warning and return nil for the parent ID,
// which will cause the folder to be created with no parent
logger.Warnf("parent path is the same as the current path: %s", path)
return nil, nil
}
parent, err := GetOrCreateFolderHierarchy(ctx, fc, parentPath, rootPaths)