refactor(submit): pass file path instead of source via stdin
Problem: Submit read the source file in Lua, piped the full content as stdin through to Python, then re-encoded it into an in-memory buffer just to hand it back to the browser's file input. Unnecessary roundtrip for AtCoder; CF also gains nothing from Lua owning the read. Solution: Pass `source_file` path as a CLI arg to the scraper instead of reading it in Lua and streaming via stdin. AtCoder calls `page.set_input_files(file_path)` directly. Codeforces reads the file with `Path(file_path).read_text()` before the browser session. Also saves the buffer with `vim.cmd.update()` before submitting.
This commit is contained in:
parent
b5a8fce13c
commit
c963728fe9
5 changed files with 22 additions and 38 deletions
|
|
@ -316,15 +316,14 @@ function M.submit(
|
|||
contest_id,
|
||||
problem_id,
|
||||
language,
|
||||
source_code,
|
||||
source_file,
|
||||
credentials,
|
||||
on_status,
|
||||
callback
|
||||
)
|
||||
local done = false
|
||||
run_scraper(platform, 'submit', { contest_id, problem_id, language }, {
|
||||
run_scraper(platform, 'submit', { contest_id, problem_id, language, source_file }, {
|
||||
ndjson = true,
|
||||
stdin = source_code,
|
||||
env_extra = { CP_CREDENTIALS = vim.json.encode(credentials) },
|
||||
on_event = function(ev)
|
||||
if ev.credentials ~= nil then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue