Address feedback from Copilot

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-08-27 19:42:23 -06:00
parent 6f4fd60d8f
commit e609c599a1
3 changed files with 37 additions and 13 deletions

View File

@@ -100,7 +100,13 @@ func (overlay Overlay) Exists() bool {
// Returns:
// - true if the overlay is a site overlay; false otherwise.
func (overlay Overlay) IsSiteOverlay() bool {
return strings.Contains(overlay.Path(), config.Get().Paths.SiteOverlaydir())
siteDir := filepath.Clean(config.Get().Paths.SiteOverlaydir())
overlayPath := filepath.Clean(overlay.Path())
if rel, err := filepath.Rel(siteDir, overlayPath); err != nil {
return false
} else {
return !strings.HasPrefix(rel, "..")
}
}
// IsDistributionOverlay determines whether the overlay is a distribution overlay.
@@ -111,7 +117,13 @@ func (overlay Overlay) IsSiteOverlay() bool {
// Returns:
// - true if the overlay is a distribution overlay; false otherwise.
func (overlay Overlay) IsDistributionOverlay() bool {
return strings.Contains(overlay.Path(), config.Get().Paths.DistributionOverlaydir())
siteDir := filepath.Clean(config.Get().Paths.DistributionOverlaydir())
overlayPath := filepath.Clean(overlay.Path())
if rel, err := filepath.Rel(siteDir, overlayPath); err != nil {
return false
} else {
return !strings.HasPrefix(rel, "..")
}
}
func (overlay Overlay) AddFile(filePath string, content []byte, parents bool, force bool) error {