upload: there was no feedback for skipped files

Massimo Melina committed Feb 19, 2024 at 00:55 UTC ae3a1b2da8c71bcaf1db5cb5abe8b5ac9fc144d6
3 files changed +16 -9
frontend/src/upload.ts
+12 -7
@@ -19,6 +19,7 @@ export const uploadState = proxy<{
19 done: number
20 doneByte: number
21 errors: number
22 + skipped: number
23 adding: ToUpload[]
24 qs: { to: string, entries: ToUpload[] }[]
25 paused: boolean
@@ -36,6 +37,7 @@ export const uploadState = proxy<{
37 paused: false,
38 qs: [],
39 adding: [],
40 + skipped: 0,
41 errors: 0,
42 doneByte: 0,
43 done: 0,
@@ -74,6 +76,7 @@ function resetCounters() {
76 errors: 0,
77 done: 0,
78 doneByte: 0,
79 + skipped: 0,
80 })
81 }
82
@@ -293,11 +296,12 @@ async function startUpload(toUpload: ToUpload, to: string, resume=0) {
296 if (req?.readyState !== 4) return
297 const status = overrideStatus || req.status
298 closeLast?.()
296 - if (status && status !== HTTP_CONFLICT) // 0 = user-aborted, HTTP_CONFLICT = skipped because existing
297 - if (status >= 400)
298 - error(status)
299 - else
300 - done()
299 + if (!status || status === HTTP_CONFLICT) // 0 = user-aborted, HTTP_CONFLICT = skipped because existing
300 + uploadState.skipped++
301 + else if (status >= 400)
302 + error(status)
303 + else
304 + done()
305 if (!resuming)
306 next()
307 }
@@ -395,10 +399,11 @@ async function startUpload(toUpload: ToUpload, to: string, resume=0) {
399 }
400
401 function UploadStatus(props: CSSProperties) {
398 - const { done, doneByte, errors } = useSnapshot(uploadState)
402 + const { done, doneByte, errors, skipped } = useSnapshot(uploadState)
403 const s = [
404 done && t('upload_finished', { n: done, size: formatBytes(doneByte) }, "{n} finished ({size})"),
401 - errors && t('upload_errors', { n: errors }, "{n} failed")
405 + skipped && t('upload_skipped', { n: skipped }, "{n} skipped"),
406 + errors && t('upload_errors', { n: errors }, "{n} failed"),
407 ].filter(Boolean).join(' – ')
408 return !s ? null : h('div', { style: props }, s)
409 }
src/langs/hfs-lang-en.json
+2 -1
@@ -158,6 +158,7 @@
158 "Shuffle": "Shuffle",
159 "Repeat": "Repeat",
160 "showHelpListShortcut": "From the file list, click holding {key} to Show quickly",
161 - "Invalid value": "Invalid value"
161 + "Invalid value": "Invalid value",
162 + "upload_skipped": "{n} skipped"
163 }
164 }
src/langs/hfs-lang-it.json
+2 -1
@@ -150,6 +150,7 @@
150 "Shuffle": "Riproduzione casuale",
151 "Repeat": "Ripeti a fine lista",
152 "showHelpListShortcut": "Dalla lista dei file, clicca tenendo {key} per accedere velocemente al File Show",
153 - "Invalid value": "Valore non valido"
153 + "Invalid value": "Valore non valido",
154 + "upload_skipped": "{n,plural, one{# saltato} other{# saltati}}"
155 }
156 }