Clear Old Assets Path
This commit is contained in:
@@ -145,10 +145,7 @@ func (p *Project) ValidateLayout() error {
|
||||
} {
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
if label == "paths.assets" && errors.Is(err, os.ErrNotExist) && p.isCachePath(path) {
|
||||
if mkErr := os.MkdirAll(path, 0o755); mkErr != nil {
|
||||
failures = append(failures, fmt.Errorf("%s: create cache directory %s: %w", label, path, mkErr))
|
||||
}
|
||||
if label == "paths.assets" && errors.Is(err, os.ErrNotExist) {
|
||||
continue
|
||||
}
|
||||
failures = append(failures, fmt.Errorf("%s: %w", label, err))
|
||||
@@ -166,15 +163,6 @@ func (p *Project) ValidateLayout() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Project) isCachePath(path string) bool {
|
||||
rel, err := filepath.Rel(p.Root, path)
|
||||
if err != nil || strings.HasPrefix(rel, ".."+string(filepath.Separator)) || rel == ".." {
|
||||
return false
|
||||
}
|
||||
parts := strings.Split(filepath.Clean(rel), string(filepath.Separator))
|
||||
return len(parts) > 0 && parts[0] == ".cache"
|
||||
}
|
||||
|
||||
func (p *Project) Scan() error {
|
||||
sourceFiles, sourceExts, err := scanDir(p.SourceDir(), func(path string) bool {
|
||||
ext := strings.ToLower(filepath.Ext(path))
|
||||
@@ -189,7 +177,11 @@ func (p *Project) Scan() error {
|
||||
return slices.Contains(AssetExtensions, ext)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("scan assets tree: %w", err)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
assetFiles = nil
|
||||
} else {
|
||||
return fmt.Errorf("scan assets tree: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
var scripts []string
|
||||
|
||||
Reference in New Issue
Block a user