Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor([bucket-record-path-helper]): derive media records dir inside exportMediaJobAndAsset
[._.]/ Adam Eivy6fba65f04d39
diff --git a/server/services/sharing/exporter.js b/server/services/sharing/exporter.jsindex e2d794df51..933ded1683 100644--- a/server/services/sharing/exporter.js+++ b/server/services/sharing/exporter.js@@ -209,7 +209,7 @@ async function jobFromSidecar(jobId) {* per-image `.metadata.json` sidecar for jobs older than the 24h archive TTL.* Returns the asset refs (image filenames) discovered.*/-async function exportMediaJobAndAsset(jobId, bucketPath, mediaRecordsDir, cache) {+async function exportMediaJobAndAsset(jobId, bucketPath, cache) {if (!jobId || !isStr(jobId)) return [];const job = getJob(jobId) || await jobFromSidecar(jobId);if (!job) {@@ -226,7 +226,7 @@ async function exportMediaJobAndAsset(jobId, bucketPath, mediaRecordsDir, cache)params: job.params,result: job.result,};- await ensureDir(mediaRecordsDir);+ await ensureDir(bucketRecordsDir(bucketPath, 'media'));await atomicWrite(bucketRecordPath(bucketPath, 'media', job.id), exported);// Copy the produced asset(s).const assetKind = job.kind === 'video' ? 'video' : 'image';@@ -455,10 +455,9 @@ export async function exportSeries(seriesId, bucketId, opts = {}) {}// Copy media-job records + their assets — run all four groups in parallel.- const mediaRecordsDir = bucketRecordsDir(bucket.path, 'media');const assetRefs = await withAssetHashCache(bucket.path, async (cache) => {const [jobRefGroups, imageRefs, videoRefs, imageRefRefs] = await Promise.all([- Promise.all([...allJobIds].map((jobId) => exportMediaJobAndAsset(jobId, bucket.path, mediaRecordsDir, cache))),+ Promise.all([...allJobIds].map((jobId) => exportMediaJobAndAsset(jobId, bucket.path, cache))),Promise.all([...allImageFiles].map((f) => copyAssetIfPresent(f, 'image', bucket.path, cache))),Promise.all([...allVideoFiles].map((f) => copyAssetIfPresent(f, 'video', bucket.path, cache))),Promise.all([...allImageRefFiles].map((f) => copyAssetIfPresent(f, 'image-ref', bucket.path, cache))),@@ -518,10 +517,9 @@ export async function exportUniverse(universeId, bucketId, opts = {}) {);const allImageRefFiles = new Set(universeRefs.directImageRefFilenames);- const mediaRecordsDir = bucketRecordsDir(bucket.path, 'media');const assetRefs = await withAssetHashCache(bucket.path, async (cache) => {const [jobRefGroups, imageRefs, videoRefs, imageRefRefs] = await Promise.all([- Promise.all([...allJobIds].map((jobId) => exportMediaJobAndAsset(jobId, bucket.path, mediaRecordsDir, cache))),+ Promise.all([...allJobIds].map((jobId) => exportMediaJobAndAsset(jobId, bucket.path, cache))),Promise.all([...allImageFiles].map((f) => copyAssetIfPresent(f, 'image', bucket.path, cache))),Promise.all([...allVideoFiles].map((f) => copyAssetIfPresent(f, 'video', bucket.path, cache))),Promise.all([...allImageRefFiles].map((f) => copyAssetIfPresent(f, 'image-ref', bucket.path, cache))),@@ -564,7 +562,6 @@ export async function exportMedia(items, bucketId) {});const manifestId = manifestStub.id;- const mediaRecordsDir = bucketRecordsDir(bucket.path, 'media');// Pre-resolve each item to a job (or null) so we know what to parallelize// and what record ids to collect for the manifest.const resolved = (items || []).flatMap((item) => {@@ -578,7 +575,7 @@ export async function exportMedia(items, bucketId) {const recordIds = resolved.filter((r) => r.job).map((r) => r.job.id);const assetRefs = await withAssetHashCache(bucket.path, async (cache) => {const results = await Promise.all(resolved.map(async (r) => {- if (r.job) return exportMediaJobAndAsset(r.job.id, bucket.path, mediaRecordsDir, cache);+ if (r.job) return exportMediaJobAndAsset(r.job.id, bucket.path, cache);const copied = await copyAssetIfPresent(r.ref, r.kind, bucket.path, cache);return copied ? [copied] : [];}));