(folder, sourceId = '')
| 185 | // Folder encryption check (used to bypass ONLYOFFICE in encrypted folders) |
| 186 | const __folderEncryptedCache = new Map(); // folder -> Promise<bool> |
| 187 | async function isFolderEncrypted(folder, sourceId = '') { |
| 188 | const f = (!folder || folder === '') ? 'root' : String(folder); |
| 189 | const sid = normalizeSourceId(sourceId); |
| 190 | const key = sid ? `${sid}::${f}` : f; |
| 191 | if (__folderEncryptedCache.has(key)) return __folderEncryptedCache.get(key); |
| 192 | const p = (async () => { |
| 193 | try { |
| 194 | const params = new URLSearchParams({ |
| 195 | folder: f, |
| 196 | t: String(Date.now()) |
| 197 | }); |
| 198 | if (sid) params.set('sourceId', sid); |
| 199 | const r = await fetch(withBase(`/api/folder/capabilities.php?${params.toString()}`), { credentials: 'include' }); |
| 200 | if (!r.ok) return false; |
| 201 | const j = await r.json().catch(() => null); |
| 202 | return !!(j && j.encryption && j.encryption.encrypted); |
| 203 | } catch (e) { |
| 204 | return false; |
| 205 | } |
| 206 | })(); |
| 207 | __folderEncryptedCache.set(key, p); |
| 208 | return p; |
| 209 | } |
| 210 | |
| 211 | // ---- script/css single-load with timeout guards ---- |
| 212 | const _loadedScripts = new Set(); |
no test coverage detected