mirror of
https://github.com/whyour/qinglong.git
synced 2026-10-18 18:33:06 +08:00
Download updates asynchronously with persistent progress and validate matching source and build artifacts before an explicit restart. Keep upgrade workers alive across service restarts, verify the new runtime, and recover the browser with a one-time success notice. Publish immutable archive sizes and checksums for accurate download progress. Align the update dialog, hide unavailable actions during transfers, and show the sidebar notice only for active, ready or failed jobs. Constrain long account names with ellipsis while preserving avatar and collapse controls.
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { readFileSync } from 'fs';
|
|
import path from 'path';
|
|
import { createHash, randomUUID } from 'crypto';
|
|
|
|
function read(filename: string): Buffer | undefined {
|
|
try {
|
|
return readFileSync(filename);
|
|
} catch {
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
function manifest(): { sourceCommit?: string } {
|
|
try {
|
|
const value = JSON.parse(
|
|
read(path.resolve(__dirname, '../../build-info.json'))?.toString() ||
|
|
'{}',
|
|
);
|
|
return value && typeof value === 'object' ? value : {};
|
|
} catch {
|
|
return {};
|
|
}
|
|
}
|
|
|
|
// Capture before serving requests. Reading the installed files on each request
|
|
// would let an old process claim the identity of a newly copied build.
|
|
const backend = read(path.resolve(__dirname, '../app.js'));
|
|
const root = process.env.QL_DIR || path.resolve(__dirname, '../../..');
|
|
const version = read(path.join(root, 'version.yaml'))
|
|
?.toString()
|
|
.match(/^\uFEFF?version:\s*["']?(\d+\.\d+\.\d+)/m)?.[1];
|
|
|
|
export const runtimeBuild = Object.freeze({
|
|
instanceId: randomUUID(),
|
|
parentPid: process.ppid,
|
|
version,
|
|
sourceCommit: manifest().sourceCommit,
|
|
backendSha256: backend
|
|
? createHash('sha256').update(backend).digest('hex')
|
|
: undefined,
|
|
});
|