dc-upkeep-7: allow larger command-file media

This commit is contained in:
Harrison Booth
2026-10-28 13:09:02 -05:00
parent d0f0d14c99
commit e0c64599cc
3 changed files with 6 additions and 5 deletions
+3 -2
View File
@@ -72,8 +72,9 @@ Each --cmd is one command: COMMAND is a command id, then `=`, then the command's
JSON object. Quote it for the shell. A command that needs no parameters is just its id.
--cmd-file FILE reads the same commands from a UTF-8 text file, one per line, avoiding shell quoting
and command-line length limits. Blank lines and full-line # comments are ignored, as is surrounding
whitespace. CRLF line endings and an optional UTF-8 BOM at the start of the file are accepted.
and command-line length limits. Each line can be up to 16 MiB, including commands with embedded
media data. Blank lines and full-line # comments are ignored, as is surrounding whitespace. CRLF
line endings and an optional UTF-8 BOM at the start of the file are accepted.
Repeat --cmd-file or mix it with --cmd: commands execute in the order those options appear.
File errors name the path; line-reading, JSON and command errors also name the line number.
+1 -1
View File
@@ -455,7 +455,7 @@ enum CommandSource {
File(String),
}
const MAX_COMMAND_FILE_LINE_BYTES: usize = 1024 * 1024;
const MAX_COMMAND_FILE_LINE_BYTES: usize = 16 * 1024 * 1024;
fn read_command_file_line(reader: &mut impl std::io::BufRead, line: &mut Vec<u8>) -> std::io::Result<bool> {
line.clear();
+2 -2
View File
@@ -146,12 +146,12 @@ fn command_file_read_errors_name_the_path_and_utf8_line() {
fn command_file_rejects_an_oversized_line_before_running_it() {
let dir = command_file_dir("line-limit");
let file = dir.join("commands.txt");
let command = format!("slide.new={{\"title\":\"{}\"}}", "x".repeat(1024 * 1024));
let command = format!("slide.new={{\"title\":\"{}\"}}", "x".repeat(16 * 1024 * 1024));
std::fs::write(&file, format!("{command}\nslide.new\n")).unwrap();
let o = cli(&["run", "--print", "--cmd-file", &file.to_string_lossy()]);
let err = stderr(&o);
assert!(err.contains(&format!("{}:1:", file.display())) && err.contains("command line exceeds 1048576 byte limit"), "{err}");
assert!(err.contains(&format!("{}:1:", file.display())) && err.contains("command line exceeds 16777216 byte limit"), "{err}");
assert!(o.stdout.is_empty(), "the oversized command must not run");
std::fs::remove_dir_all(dir).unwrap();
}