Better handle download errors

This commit is contained in:
2023-06-13 14:26:09 +02:00
parent eff4b366ce
commit c617997017
3 changed files with 24 additions and 6 deletions

View File

@@ -18,6 +18,10 @@ let download_captcha_window
let captcha_type = "" // rate_limit or malware let captcha_type = "" // rate_limit or malware
let captcha_window_title = "" let captcha_window_title = ""
let captcha_container let captcha_container
let error_window = null
let error_code = ""
let error_message = ""
export const download_file = () => { export const download_file = () => {
if (!window.viewer_data.captcha_key) { if (!window.viewer_data.captcha_key) {
console.debug("Server doesn't support captcha, starting download") console.debug("Server doesn't support captcha, starting download")
@@ -30,7 +34,10 @@ export const download_file = () => {
return return
} }
if (!file.availability.endsWith("_captcha_required")) { if (!file.availability.endsWith("_captcha_required")) {
console.debug("File is unavailable, ignoring download request") error_code = file.availability
error_message = file.availability_message
error_window.show()
console.debug("File is unavailable, showing error message")
return return
} }
@@ -115,6 +122,15 @@ export const download_list = () => {
<div bind:this={captcha_container} class="captcha_container"></div> <div bind:this={captcha_container} class="captcha_container"></div>
</Modal> </Modal>
<Modal bind:this={error_window} title="Download error" width="500px" padding>
<p>
Can't download file: {error_code}
</p>
<p>
{error_message}
</p>
</Modal>
<style> <style>
.download_frame { .download_frame {
position: absolute; position: absolute;

View File

@@ -448,10 +448,11 @@ const keyboard_event = evt => {
<div class="separator"></div> <div class="separator"></div>
{#if view === "file" && file.can_download && !disable_download_button} {#if view === "file" && !disable_download_button}
<button <button
on:click={downloader.download_file} on:click={downloader.download_file}
class="toolbar_button" class="toolbar_button"
class:button_red={file.can_download === false}
title="Save this file to your computer"> title="Save this file to your computer">
<i class="icon">download</i> <i class="icon">download</i>
<span>Download</span> <span>Download</span>

View File

@@ -108,10 +108,11 @@ const logout = async (key) => {
<p> <p>
If you delete the API key that you are currently using you will be If you delete the API key that you are currently using you will be
logged out of your account. API keys expire 30 days after the last logged out of your account. Keys are sorted based on how recently they
time they're used. If you think someone is using your account were used, so your session usually the top one. API keys expire 30 days
without your authorization it's probably a good idea to delete all after the last time they're used. If you think someone is using your
your keys. account without your authorization it's probably a good idea to delete
all your keys.
</p> </p>
</section> </section>
<div class="table_scroll"> <div class="table_scroll">