Skip to content

Commit

Permalink
check request failure when mirroring
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm authored and leafo committed Aug 14, 2023
1 parent a45b250 commit f4a6176
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion helpers/mirror.moon
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,20 @@ update_manifest_on_disk = (server, dest, force=false) ->

tmp_fname = "#{fname}.tmp"

http.request {
res, status = http.request {
:url
sink: ltn12.sink.file io.open tmp_fname, "w"
headers: {
"user-agent": "moonrocks_backup"
}
}

if (not res) or (type(status) == "number" and status >= 400)
seen_files[fname] = nil
os.execute "rm '#{tmp_fname}'"
print "failed"
continue

os.execute "mv '#{tmp_fname}' #{fname}"
print "done"

Expand Down

0 comments on commit f4a6176

Please sign in to comment.