feat: complete TASK-WP0-08 logging
This commit is contained in:
@@ -134,6 +134,7 @@ export class ManagedStorage {
|
||||
private readonly database: BetterSqlite3.Database;
|
||||
private dataRootWritable = true;
|
||||
private diskSpaceAvailable = true;
|
||||
private logWritable = true;
|
||||
private sqliteWritable = true;
|
||||
private measurementBaselineBytes = 0;
|
||||
private recoveryRequiresRemeasure = false;
|
||||
@@ -241,7 +242,7 @@ export class ManagedStorage {
|
||||
getState(): StorageStateRow {
|
||||
const state = this.database.prepare("SELECT * FROM local_backend_storage_state WHERE singleton = 1").get() as Omit<StorageStateRow, "active_storage_reservations_bytes">;
|
||||
const withReservations = { ...state, active_storage_reservations_bytes: this.activeReservationBytes() };
|
||||
if (!this.dataRootWritable || !this.diskSpaceAvailable || !this.sqliteWritable) {
|
||||
if (!this.dataRootWritable || !this.diskSpaceAvailable || !this.sqliteWritable || !this.logWritable) {
|
||||
return { ...withReservations, storage_status: "unavailable" };
|
||||
}
|
||||
return withReservations;
|
||||
@@ -260,7 +261,7 @@ export class ManagedStorage {
|
||||
if (!this.sqliteWritable) return;
|
||||
const state = this.database.prepare("SELECT managed_content_bytes FROM local_backend_storage_state WHERE singleton = 1").get() as { managed_content_bytes: number };
|
||||
const classification = classifyCapacity(state.managed_content_bytes, this.activeReservationBytes());
|
||||
const storageStatus = !this.dataRootWritable || !this.diskSpaceAvailable || this.recoveryRequiresRemeasure
|
||||
const storageStatus = !this.dataRootWritable || !this.diskSpaceAvailable || !this.logWritable || this.recoveryRequiresRemeasure
|
||||
? "unavailable"
|
||||
: classification.storage_status;
|
||||
this.database.prepare(`
|
||||
@@ -291,6 +292,12 @@ export class ManagedStorage {
|
||||
this.refreshState();
|
||||
}
|
||||
|
||||
setLogAvailability(writable: boolean) {
|
||||
this.logWritable = writable;
|
||||
if (!writable) this.recoveryRequiresRemeasure = true;
|
||||
this.refreshState();
|
||||
}
|
||||
|
||||
private physicalManagedBytes() {
|
||||
return ["content", "managed-assets", "derived-assets"]
|
||||
.flatMap((root) => listFiles(resolvePathWithinRoot(this.dataRoot, root)))
|
||||
|
||||
Reference in New Issue
Block a user