This commit is contained in:
@@ -44,14 +44,23 @@ import json, os, sys, tempfile
|
||||
from datetime import datetime, timezone
|
||||
|
||||
path, phase, progress, message, version, error = sys.argv[1:]
|
||||
payload = {
|
||||
payload = {}
|
||||
try:
|
||||
if os.path.getsize(path) <= 64 * 1024:
|
||||
with open(path, encoding="utf-8") as handle:
|
||||
existing = json.load(handle)
|
||||
if isinstance(existing, dict):
|
||||
payload = existing
|
||||
except (OSError, json.JSONDecodeError, TypeError, ValueError):
|
||||
pass
|
||||
payload.update({
|
||||
"phase": phase,
|
||||
"progress": int(progress),
|
||||
"message": message,
|
||||
"version": version or None,
|
||||
"error": error or None,
|
||||
"updatedAt": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
|
||||
}
|
||||
})
|
||||
parent = os.path.dirname(path) or "."
|
||||
fd, tmp = tempfile.mkstemp(prefix=".update-state-", dir=parent, text=True)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user