Skip to content

Instantly share code, notes, and snippets.

@JensRantil
Last active November 26, 2025 14:26
Show Gist options
  • Select an option

  • Save JensRantil/3da3cb3dc90a7eefb3ef304779570b56 to your computer and use it in GitHub Desktop.

Select an option

Save JensRantil/3da3cb3dc90a7eefb3ef304779570b56 to your computer and use it in GitHub Desktop.
Race condition bug in CUE.
package maklare
import "tool/file"
import "tool/cli"
import ppath "path"
import "list"
command: process: {
inputs: file.Glob & {
glob: "input/*.json"
}
outputs: file.Glob & {
glob: "output/*.json"
}
for _, filepath in inputs.files {
(filepath): {
metadata: {
_base: ppath.Base(filepath)
_output: ppath.Join(["output", _base], ppath.Unix)
_already_processed: list.Contains(outputs.files, metadata._output)
}
if metadata._already_processed == false {
print_what_to_execute: cli.Print & {
text: "Processing: input=\(filepath) output=\(metadata._output)"
}
}
if metadata._already_processed == true {
print_already_processed: cli.Print & {
text: "\(filepath) already processed. Skipping."
}
}
}
}
}
command: testdata: {
mkdirInputs: file.Mkdir & {
path: "input"
}
mkdirOutputs: file.Mkdir & {
path: "output"
}
for _, integer in list.Range(1, 1000, 1) {
"createInput\(integer)": file.Create & {
filename: "input/\(integer).json"
contents: "{}"
$after: mkdirInputs
}
"createOutput\(integer)": file.Create & {
filename: "output/\(integer).json"
contents: "{}"
$after: mkdirOutputs
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment