pithos/core/prefs.js
Local Dev 77a29d2ce8 Pithos 0.3.5: s3d stays up, one view at a time, user buckets, a viewer
- s3d kept stopping: Pithos stopped it whenever the extension restarted
  (every update, every Theseus quit) and never started it again. Start
  and Stop now record what the user wants (pithos-prefs.json beside
  s3d.yml); Pithos starts s3d with Theseus and when opened, and retries a
  crash up to three times in ten minutes, logging why it skips. The
  Buckets page also redraws when s3d starts or stops; it used to keep
  saying "not running".
- One view at a time: "Full page" opens Pithos in a tab and closes the
  left panel; the tab has "Back to sidebar", which reopens the panel.
- Every new user gets a bucket of their own, named after them (lowercase,
  hyphens) or as typed in the New user dialog.
- Buckets show as folder tiles. New folders are kept while empty with the
  usual "<name>/" marker object.
- A viewer: images, audio (mp3 and friends), video and text open inside
  Pithos, with Share and Download. The Theseus panel uses 10-minute,
  reusable, inline view links so players can make range requests.
- The Access dialog says what s3d cannot do: per-folder public access and
  write rights for others are not supported, only whole-bucket public read.
2026-10-04 00:05:49 +02:00

21 lines
833 B
JavaScript

// Small Pithos preferences kept beside s3d.yml (pithos-prefs.json):
// whether s3d should be running, so a restart of the host (Theseus quitting,
// an extension update) brings it back instead of leaving it stopped.
import fs from 'node:fs';
import path from 'node:path';
const FILE = 'pithos-prefs.json';
export function readPrefs(configFile) {
try { return JSON.parse(fs.readFileSync(path.join(path.dirname(configFile), FILE), 'utf8')) || {}; } catch { return {}; }
}
export function writePrefs(configFile, patch) {
const next = { ...readPrefs(configFile), ...patch };
try {
fs.mkdirSync(path.dirname(configFile), { recursive: true });
fs.writeFileSync(path.join(path.dirname(configFile), FILE), JSON.stringify(next, null, 2));
} catch { /* a read-only config folder just means no memory */ }
return next;
}