Fix folder path resolution for instance targets in WriteResourceFileFromObject

Add fallback mechanism to handle folder resolution when rootFolder is empty
(instance targets). First try DirPath with rootFolder, then fallback to
DirPath without rootFolder if the first attempt fails.
This commit is contained in:
Roberto Jimenez Sanchez
2025-12-02 17:26:43 +01:00
parent cb18f50de5
commit 64949f26e8
@@ -183,7 +183,11 @@ func (r *ResourcesManager) WriteResourceFileFromObject(ctx context.Context, obj
var ok bool
fid, ok = r.folders.Tree().DirPath(folder, rootFolder)
if !ok {
return "", fmt.Errorf("folder %s NOT found in tree with root: %s", folder, rootFolder)
// Fallback: try without rootFolder (for instance targets where rootFolder is empty)
fid, ok = r.folders.Tree().DirPath(folder, "")
if !ok {
return "", fmt.Errorf("folder %s NOT found in tree", folder)
}
}
}