From d4d33f3aa2b2b6b7b31141ccd8fa9efa888cb0f2 Mon Sep 17 00:00:00 2001 From: iusmac Date: Thu, 1 May 2025 09:26:01 +0200 Subject: [PATCH] fix: handle OS-specific restrictions when moving `Output` frames Signed-off-by: iusmac --- evaluator.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/evaluator.go b/evaluator.go index ab9f68715..f47219a20 100644 --- a/evaluator.go +++ b/evaluator.go @@ -117,7 +117,15 @@ func Evaluate(ctx context.Context, tape string, out io.Writer, opts ...Evaluator defer func() { if v.Options.Video.Output.Frames != "" { // Move the frames to the output directory. - _ = os.Rename(v.Options.Video.Input, v.Options.Video.Output.Frames) + err := os.Rename(v.Options.Video.Input, v.Options.Video.Output.Frames) + if err != nil { + // On some systems, Rename may fail with the error message + // "invalid cross-device link" when source and target are on + // different mounts. It may also fail, if the target (output) + // directory already exists, even if it's empty. CopyFS can + // handle the above, while keeping the existing files intact. + _ = os.CopyFS(v.Options.Video.Output.Frames, os.DirFS(v.Options.Video.Input)) + } } _ = v.Cleanup()