mirror of
https://github.com/stashapp/stash.git
synced 2026-04-20 13:27:57 -05:00
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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user