Don't crash when referenced file not found
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -316,6 +317,10 @@ func preprocessInstructions(instructions []LinkInstruction, filename, workdir st
|
|||||||
// This is a from reference - load the referenced file
|
// This is a from reference - load the referenced file
|
||||||
fromInstructions, err := loadFromReference(instr.Source, filename, workdir, visited)
|
fromInstructions, err := loadFromReference(instr.Source, filename, workdir, visited)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
|
LogError("Referenced file not found: %s (from %s), skipping", instr.Source, filename)
|
||||||
|
continue
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("error loading from reference %s: %w", instr.Source, err)
|
return nil, fmt.Errorf("error loading from reference %s: %w", instr.Source, err)
|
||||||
}
|
}
|
||||||
result = append(result, fromInstructions...)
|
result = append(result, fromInstructions...)
|
||||||
@@ -445,6 +450,8 @@ func ExpandPattern(source, workdir, target string) (links []LinkInstruction, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error converting home directory in source %s: %w", source, err)
|
return nil, fmt.Errorf("error converting home directory in source %s: %w", source, err)
|
||||||
}
|
}
|
||||||
|
// Normalize path to convert backslashes to forward slashes before pattern processing
|
||||||
|
source = NormalizePath(source, workdir)
|
||||||
static, pattern := doublestar.SplitPattern(source)
|
static, pattern := doublestar.SplitPattern(source)
|
||||||
if static == "" || static == "." {
|
if static == "" || static == "." {
|
||||||
static = workdir
|
static = workdir
|
||||||
|
|||||||
Reference in New Issue
Block a user