mirror of
https://github.com/stashapp/stash.git
synced 2026-05-08 20:58:48 +02: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:
parent
3b8f6bd94c
commit
c7e1c3da69
2 changed files with 6 additions and 2 deletions
|
|
@ -42,7 +42,8 @@ func (s StashConfigs) GetStashFromDirPath(dirPath string) *StashConfig {
|
||||||
func (s StashConfigs) Paths() []string {
|
func (s StashConfigs) Paths() []string {
|
||||||
paths := make([]string, len(s))
|
paths := make([]string, len(s))
|
||||||
for i, c := range 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
|
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,
|
// safety check - don't allow parent path to be the same as the current path,
|
||||||
// otherwise we could end up in an infinite loop
|
// otherwise we could end up in an infinite loop
|
||||||
if parentPath == path {
|
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)
|
parent, err := GetOrCreateFolderHierarchy(ctx, fc, parentPath, rootPaths)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue