Skip to content

Commit c2af7a5

Browse files
committed
Revert "update.nim: env-gated diagnostic log via THREECODE_UPDATE_LOG"
This reverts commit ff60285.
1 parent ff60285 commit c2af7a5

1 file changed

Lines changed: 13 additions & 49 deletions

File tree

‎src/threecode/update.nim‎

Lines changed: 13 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,6 @@ const
2323
Repo = "capocasa/3code"
2424
ThrottleSecs = 4 * 60 * 60
2525

26-
proc dbgLog(stage: string) =
27-
## Append a timestamped line to `$THREECODE_UPDATE_LOG` if set.
28-
## No-op otherwise. Inherits across `execv` so the grandchild's trace
29-
## lands in the same file as the parent's. Diagnostic only — there is
30-
## no release-mode use of this.
31-
let path = getEnv("THREECODE_UPDATE_LOG")
32-
if path.len == 0: return
33-
try:
34-
let f = open(path, fmAppend)
35-
defer: f.close()
36-
f.writeLine($epochTime().int & " [" & $getCurrentProcessId() & "] " & stage)
37-
except CatchableError: discard
38-
3926
const Tarball =
4027
when defined(linux) and (defined(amd64) or defined(x86_64)):
4128
"3code-linux-amd64.tar.gz"
@@ -152,31 +139,20 @@ proc selfUpdateCheck*(curVersion = Version, targetPath = "",
152139
## "running version" and the binary path so the live pipeline can be
153140
## exercised without affecting the installed binary. `force` skips
154141
## the config gate (tests + manual invocation override).
155-
dbgLog("selfUpdateCheck enter cur=" & curVersion & " force=" & $force)
156-
if not force and not autoUpdateEnabled():
157-
dbgLog("selfUpdateCheck gate=disabled"); return
158-
if Tarball.len == 0:
159-
dbgLog("selfUpdateCheck tarball=empty"); return
142+
if not force and not autoUpdateEnabled(): return
143+
if Tarball.len == 0: return
160144
let latest = fetchLatestTag()
161-
dbgLog("selfUpdateCheck latest=" & latest)
162145
if latest.len == 0: return
163-
if not semverGt(latest, curVersion):
164-
dbgLog("selfUpdateCheck not-newer"); return
146+
if not semverGt(latest, curVersion): return
165147
let cache = userDataRoot() / "update"
166-
try: createDir(cache)
167-
except CatchableError as e:
168-
dbgLog("selfUpdateCheck mkdir-failed " & e.msg); return
148+
try: createDir(cache) except CatchableError: return
169149
let tarPath = cache / Tarball
170-
if not downloadAsset(latest, Tarball, tarPath):
171-
dbgLog("selfUpdateCheck download-failed " & tarPath); return
172-
dbgLog("selfUpdateCheck downloaded size=" & $getFileSize(tarPath))
150+
if not downloadAsset(latest, Tarball, tarPath): return
173151
let extractDir = cache / "extract"
174152
let bin = extractTarball(tarPath, extractDir)
175-
if bin.len == 0:
176-
dbgLog("selfUpdateCheck extract-failed"); return
153+
if bin.len == 0: return
177154
let dest = if targetPath.len > 0: targetPath else: getAppFilename()
178-
let ok = swapBinary(bin, dest)
179-
dbgLog("selfUpdateCheck swap=" & $ok & " dest=" & dest)
155+
discard swapBinary(bin, dest)
180156
try: removeFile(tarPath) except CatchableError: discard
181157
try: removeDir(extractDir) except CatchableError: discard
182158

@@ -187,40 +163,28 @@ when defined(posix):
187163
## Double-fork + setsid so the worker survives the parent exiting and
188164
## SIGHUP from the controlling terminal. Throttle is claimed before
189165
## the fork so concurrent launches don't pile up.
190-
dbgLog("spawn enter")
191-
if not autoUpdateEnabled() or Tarball.len == 0:
192-
dbgLog("spawn gate=disabled-or-noplatform"); return
193-
if not throttleExpired():
194-
dbgLog("spawn throttled"); return
166+
if not autoUpdateEnabled() or Tarball.len == 0: return
167+
if not throttleExpired(): return
195168
touchThrottle()
196169
let pid = posix.fork()
197-
if pid < 0:
198-
dbgLog("spawn fork1-failed"); return
170+
if pid < 0: return
199171
if pid > 0:
200172
var status: cint
201173
discard posix.waitpid(pid, status, 0)
202-
dbgLog("spawn parent waitpid done")
203174
return
204-
dbgLog("spawn child1 setsid")
205175
discard posix.setsid()
206176
let pid2 = posix.fork()
207-
if pid2 < 0:
208-
dbgLog("spawn fork2-failed"); quit(1)
209-
if pid2 > 0:
210-
dbgLog("spawn intermediate exit")
211-
quit(0)
212-
dbgLog("spawn grandchild dup2")
177+
if pid2 < 0: quit(1)
178+
if pid2 > 0: quit(0)
213179
let fd = posix.open("/dev/null", O_RDWR)
214180
if fd >= 0:
215181
discard posix.dup2(fd, 0)
216182
discard posix.dup2(fd, 1)
217183
discard posix.dup2(fd, 2)
218184
if fd > 2: discard posix.close(fd)
219185
let exe = getAppFilename()
220-
dbgLog("spawn grandchild execv " & exe)
221186
let argv = allocCStringArray([exe, "--self-update-check"])
222-
let rc = posix.execv(exe.cstring, argv)
223-
dbgLog("spawn grandchild execv-returned rc=" & $rc & " errno=" & $errno)
187+
discard posix.execv(exe.cstring, argv)
224188
quit(1)
225189
else:
226190
proc spawnBackgroundUpdateMaybe*() = discard

0 commit comments

Comments
 (0)