mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
refactor(daemon): use mtime-based version detection instead of string comparison
Replace CLI version string comparison with file modification time (mtime) based detection. This provides a more reliable way to detect when the CLI binary has been updated, especially for bun-compiled executables where package.json may not be accessible. Changes: - Add getInstalledCliMtimeMs() utility to check CLI binary or package.json mtime - Store startedWithCliMtimeMs in daemon state on startup - Use mtime comparison in version check loop for daemon auto-restart - Move version flag handling to early CLI startup before daemon initialization - Fix machine active state merging to prefer newer activeAt timestamp This improves daemon restart behavior when CLI is updated via package managers.
This commit is contained in:
@@ -476,13 +476,17 @@ export class SyncEngine {
|
||||
return { host, platform, happyCliVersion, displayName, ...data }
|
||||
})()
|
||||
|
||||
const storedActiveAt = stored.activeAt ?? stored.createdAt
|
||||
const existingActiveAt = existing?.activeAt ?? 0
|
||||
const useStoredActivity = storedActiveAt > existingActiveAt
|
||||
|
||||
const machine: Machine = {
|
||||
id: stored.id,
|
||||
seq: stored.seq,
|
||||
createdAt: stored.createdAt,
|
||||
updatedAt: stored.updatedAt,
|
||||
active: existing?.active ?? stored.active,
|
||||
activeAt: existing?.activeAt ?? (stored.activeAt ?? stored.createdAt),
|
||||
active: useStoredActivity ? stored.active : (existing?.active ?? stored.active),
|
||||
activeAt: useStoredActivity ? storedActiveAt : (existingActiveAt || storedActiveAt),
|
||||
metadata,
|
||||
metadataVersion: stored.metadataVersion,
|
||||
daemonState: stored.daemonState,
|
||||
|
||||
Reference in New Issue
Block a user