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

Function fetchFolderSummaryStats

public/js/fileListView.js:3176–3205  ·  view source on GitHub ↗
(folder, depthOverride, sourceId = '')

Source from the content-addressed store, hash-verified

3174}
3175
3176function fetchFolderSummaryStats(folder, depthOverride, sourceId = '') {
3177 if (!folder) return Promise.resolve(null);
3178 if (isSlowRemoteSource(sourceId)) {
3179 return Promise.resolve(null);
3180 }
3181
3182 const depthSetting = Number.isFinite(depthOverride) ? depthOverride : getFileListSummaryDepth();
3183 const depth = Math.max(MIN_FILE_LIST_SUMMARY_DEPTH, Math.min(MAX_FILE_LIST_SUMMARY_DEPTH, depthSetting));
3184 const depthKey = depth > 0 ? String(depth) : 'u';
3185 const baseKey = folderCacheKey(folder, sourceId);
3186 const cacheKey = `${baseKey}::${depthKey}`;
3187
3188 if (_folderSummaryCache.has(cacheKey)) {
3189 return _folderSummaryCache.get(cacheKey);
3190 }
3191
3192 const depthParam = depth > 0 ? `&depth=${depth}` : '';
3193 const sourceParam = sourceId ? `&sourceId=${encodeURIComponent(sourceId)}` : '';
3194 const url = withBase(`/api/folder/isEmpty.php?folder=${encodeURIComponent(folder)}&deep=1${depthParam}${sourceParam}&t=${Date.now()}`);
3195 const p = _fetchJSONWithTimeout(url, 6000).then(data => {
3196 if (data && data.__fr_err) {
3197 _folderSummaryCache.delete(cacheKey);
3198 return null;
3199 }
3200 return data || null;
3201 });
3202
3203 _folderSummaryCache.set(cacheKey, p);
3204 return p;
3205}
3206
3207function clearFolderSummaryCache(folder, sourceId = '') {
3208 if (!folder) return;

Callers 2

loadFileListFunction · 0.85

Calls 8

isSlowRemoteSourceFunction · 0.85
getFileListSummaryDepthFunction · 0.85
folderCacheKeyFunction · 0.85
withBaseFunction · 0.85
_fetchJSONWithTimeoutFunction · 0.85
setMethod · 0.80
getMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected