atmosphere explorer
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix using for safari

Juliet cd7e6180 22fd9fd1

+53 -41
+53 -41
src/views/car/unpack.tsx
··· 41 41 42 42 // Create async generator that yields ZipEntry as we read from CAR 43 43 const entryGenerator = async function* (): AsyncGenerator<ZipEntry> { 44 - using progress = logger.progress(`Unpacking records (0 entries)`); 44 + const progress = logger.progress(`Unpacking records (0 entries)`); 45 45 46 - for await (const entry of repo) { 47 - if (signal.aborted) return; 46 + try { 47 + for await (const entry of repo) { 48 + if (signal.aborted) return; 48 49 49 - // Prompt for save location on first record 50 - if (writable === undefined) { 51 - using _waiting = logger.progress(`Waiting for user...`); 50 + // Prompt for save location on first record 51 + if (writable === undefined) { 52 + const waiting = logger.progress(`Waiting for user...`); 52 53 53 - const fd = await showSaveFilePicker({ 54 - suggestedName: `${file.name.replace(/\.car$/, "")}.zip`, 55 - // @ts-expect-error: ponyfill doesn't have full typings 56 - id: "car-unpack", 57 - startIn: "downloads", 58 - types: [ 59 - { 60 - description: "ZIP archive", 61 - accept: { "application/zip": [".zip"] }, 62 - }, 63 - ], 64 - }).catch((err) => { 65 - if (err instanceof DOMException && err.name === "AbortError") { 66 - logger.warn(`File picker was cancelled`); 67 - } else { 68 - console.warn(err); 69 - logger.warn(`Something went wrong when opening the file picker`); 70 - } 71 - return undefined; 72 - }); 54 + try { 55 + const fd = await showSaveFilePicker({ 56 + suggestedName: `${file.name.replace(/\.car$/, "")}.zip`, 57 + // @ts-expect-error: ponyfill doesn't have full typings 58 + id: "car-unpack", 59 + startIn: "downloads", 60 + types: [ 61 + { 62 + description: "ZIP archive", 63 + accept: { "application/zip": [".zip"] }, 64 + }, 65 + ], 66 + }).catch((err) => { 67 + if (err instanceof DOMException && err.name === "AbortError") { 68 + logger.warn(`File picker was cancelled`); 69 + } else { 70 + console.warn(err); 71 + logger.warn(`Something went wrong when opening the file picker`); 72 + } 73 + return undefined; 74 + }); 73 75 74 - writable = await fd?.createWritable(); 76 + writable = await fd?.createWritable(); 75 77 76 - if (writable === undefined) { 77 - return; 78 + if (writable === undefined) { 79 + return; 80 + } 81 + } finally { 82 + waiting[Symbol.dispose]?.(); 83 + } 78 84 } 79 - } 80 85 81 - try { 82 - const record = toJsonValue(entry.record); 83 - const filename = `${entry.collection}/${filenamify(entry.rkey)}.json`; 84 - const data = JSON.stringify(record, null, 2); 86 + try { 87 + const record = toJsonValue(entry.record); 88 + const filename = `${entry.collection}/${filenamify(entry.rkey)}.json`; 89 + const data = JSON.stringify(record, null, 2); 85 90 86 - yield { filename, data, compress: "deflate" }; 87 - count++; 88 - progress.update(`Unpacking records (${count} entries)`); 89 - } catch { 90 - // Skip entries with invalid data 91 + yield { filename, data, compress: "deflate" }; 92 + count++; 93 + progress.update(`Unpacking records (${count} entries)`); 94 + } catch { 95 + // Skip entries with invalid data 96 + } 91 97 } 98 + } finally { 99 + progress[Symbol.dispose]?.(); 92 100 } 93 101 }; 94 102 ··· 123 131 logger.log(`${count} records extracted`); 124 132 125 133 { 126 - using _progress = logger.progress(`Flushing writes...`); 127 - await writable.close(); 134 + const flushProgress = logger.progress(`Flushing writes...`); 135 + try { 136 + await writable.close(); 137 + } finally { 138 + flushProgress[Symbol.dispose]?.(); 139 + } 128 140 } 129 141 130 142 logger.log(`Finished!`);