Better handle download errors
This commit is contained in:
@@ -18,6 +18,10 @@ let download_captcha_window
|
||||
let captcha_type = "" // rate_limit or malware
|
||||
let captcha_window_title = ""
|
||||
let captcha_container
|
||||
|
||||
let error_window = null
|
||||
let error_code = ""
|
||||
let error_message = ""
|
||||
export const download_file = () => {
|
||||
if (!window.viewer_data.captcha_key) {
|
||||
console.debug("Server doesn't support captcha, starting download")
|
||||
@@ -30,7 +34,10 @@ export const download_file = () => {
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -115,6 +122,15 @@ export const download_list = () => {
|
||||
<div bind:this={captcha_container} class="captcha_container"></div>
|
||||
</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>
|
||||
.download_frame {
|
||||
position: absolute;
|
||||
|
@@ -448,10 +448,11 @@ const keyboard_event = evt => {
|
||||
|
||||
<div class="separator"></div>
|
||||
|
||||
{#if view === "file" && file.can_download && !disable_download_button}
|
||||
{#if view === "file" && !disable_download_button}
|
||||
<button
|
||||
on:click={downloader.download_file}
|
||||
class="toolbar_button"
|
||||
class:button_red={file.can_download === false}
|
||||
title="Save this file to your computer">
|
||||
<i class="icon">download</i>
|
||||
<span>Download</span>
|
||||
|
@@ -108,10 +108,11 @@ const logout = async (key) => {
|
||||
|
||||
<p>
|
||||
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
|
||||
time they're used. If you think someone is using your account
|
||||
without your authorization it's probably a good idea to delete all
|
||||
your keys.
|
||||
logged out of your account. Keys are sorted based on how recently they
|
||||
were used, so your session usually the top one. API keys expire 30 days
|
||||
after the last time they're used. If you think someone is using your
|
||||
account without your authorization it's probably a good idea to delete
|
||||
all your keys.
|
||||
</p>
|
||||
</section>
|
||||
<div class="table_scroll">
|
||||
|
Reference in New Issue
Block a user