Last active
November 26, 2025 14:26
-
-
Save JensRantil/3da3cb3dc90a7eefb3ef304779570b56 to your computer and use it in GitHub Desktop.
Race condition bug in CUE.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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