(names, fileList)
| 196 | } |
| 197 | |
| 198 | function 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) ---------------- */ |
| 231 | export function fileDragStartHandler(event) { |
no test coverage detected