MCPcopy Create free account
hub / github.com/error311/FileRise / resolvePreviewSourceId

Function resolvePreviewSourceId

public/js/filePreview.js:21–46  ·  view source on GitHub ↗
(sourceId, folder, name)

Source from the content-addressed store, hash-verified

19}
20
21function resolvePreviewSourceId(sourceId, folder, name) {
22 let sid = String(sourceId || '').trim();
23 if (sid) return sid;
24 const fParam = (!folder || folder === '') ? 'root' : String(folder);
25 try {
26 if (Array.isArray(fileData)) {
27 const meta = fileData.find(
28 f => f.name === name && (f.folder || 'root') === fParam
29 );
30 if (meta && meta.sourceId) return String(meta.sourceId || '').trim();
31 }
32 } catch (e) { /* ignore */ }
33 try {
34 if (typeof window.__frGetActiveSourceId === 'function') {
35 const v = window.__frGetActiveSourceId();
36 if (v) return String(v).trim();
37 }
38 } catch (e) { /* ignore */ }
39 const sel = document.getElementById('sourceSelector');
40 if (sel && sel.value) return String(sel.value).trim();
41 try {
42 const stored = localStorage.getItem('fr_active_source');
43 if (stored) return stored;
44 } catch (e) { /* ignore */ }
45 return '';
46}
47
48// Build a preview URL that always goes through the API layer (respects ACLs/UPLOAD_DIR)
49export function buildPreviewUrl(folder, name, sourceId = '') {

Callers 2

buildPreviewUrlFunction · 0.85
buildDownloadUrlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected