skin studio updates, save sync CLOSES #1533

This commit is contained in:
bryanthaboi
2026-08-19 05:57:44 -04:00
parent fd73ab2a11
commit 93374fbbbb
54 changed files with 9762 additions and 271 deletions
+9
View File
@@ -86,6 +86,7 @@ local function drain()
else
j.status = msg.ok and "ok" or "error"
j.body, j.err, j.path = msg.body, msg.err, msg.path
j.code = msg.code
j.progress = msg.ok and 1 or j.progress
end
end
@@ -143,6 +144,14 @@ function Fetch.post(url, body, opts)
contentType = opts.contentType, maxSeconds = opts.maxSeconds })
end
function Fetch.request(url, opts)
opts = opts or {}
return submit({ kind = "request", url = url,
method = opts.method, body = opts.body, headers = opts.headers,
userAgent = opts.userAgent or "gen1recomp",
maxSeconds = opts.maxSeconds })
end
-- Download a URL to `saveRel`, a path relative to the LOVE save directory.
-- Progress is reported as a 0..1 fraction when `size` is known.
function Fetch.download(url, saveRel, opts)
+19
View File
@@ -113,6 +113,22 @@ local function doPost(job)
post({ id = job.id, ok = true, done = true })
end
local function doRequest(job)
if not HostShell then
post({ id = job.id, ok = false, err = "no transport" })
return
end
local body, err, code = HostShell.httpRequest(job.url, {
method = job.method, body = job.body, headers = job.headers,
userAgent = job.userAgent,
maxTime = tonumber(job.maxSeconds) or GET_MAX_SECONDS })
if not code then
post({ id = job.id, ok = false, err = err or "request failed" })
return
end
post({ id = job.id, ok = true, body = body or "", code = code, done = true })
end
while true do
local job = cmdCh:demand()
-- The flag is checked before the job's KIND, so a worker woken by a
@@ -131,6 +147,9 @@ while true do
elseif job.kind == "post" then
local ok, err = pcall(doPost, job)
if not ok then post({ id = job.id, ok = false, err = tostring(err) }) end
elseif job.kind == "request" then
local ok, err = pcall(doRequest, job)
if not ok then post({ id = job.id, ok = false, err = tostring(err) }) end
elseif job.kind == "download" then
local ok, err = pcall(doDownload, job)
if not ok then post({ id = job.id, ok = false, err = tostring(err) }) end