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

Function getTransferTotalsForNames

public/js/fileDragDrop.js:198–228  ·  view source on GitHub ↗
(names, fileList)

Source from the content-addressed store, hash-verified

196}
197
198function getTransferTotalsForNames(names, fileList) {
199 const list = Array.isArray(names) ? names : [];
200 const wanted = new Set(list.map(name => String(name || '')));
201 const files = Array.isArray(fileList) ? fileList : [];
202
203 let totalBytes = 0;
204 let matched = 0;
205 let unknown = 0;
206
207 files.forEach(file => {
208 if (!file || !file.name) return;
209 const raw = String(file.name);
210 const esc = escapeHTML(raw);
211 if (!wanted.has(raw) && !wanted.has(esc)) return;
212 matched += 1;
213 if (Number.isFinite(file.sizeBytes)) {
214 totalBytes += file.sizeBytes;
215 } else {
216 unknown += 1;
217 }
218 });
219
220 const missing = Math.max(0, list.length - matched);
221 if (missing) unknown += missing;
222
223 return {
224 totalBytes,
225 bytesKnown: unknown === 0 && totalBytes > 0,
226 itemCount: list.length
227 };
228}
229
230/* ---------------- drag start (rows/cards) ---------------- */
231export function fileDragStartHandler(event) {

Callers 1

fileDragStartHandlerFunction · 0.70

Calls 1

escapeHTMLFunction · 0.85

Tested by

no test coverage detected