misc fixes:

- don't attempt to resolve sourceUrl (breaks file urls)
- pass blob to loader
- add exact size progress update, if available
- google drive loader: switch to manual auth for any error
This commit is contained in:
Ilya Kreymer
2020-06-10 08:35:02 -07:00
parent 6ed0e510e2
commit b6f70975be
7 changed files with 63 additions and 38 deletions
+4 -2
View File
@@ -39,7 +39,9 @@ class Chooser extends LitElement
loadInfo.loadUrl = url.href;
} else {
loadInfo.loadUrl = URL.createObjectURL(this.file);
loadInfo.blob = this.file;
}
loadInfo.size = this.file.size;
loadInfo.noCache = this.file.path !== undefined;
loadInfo.name = this.fileDisplayName;
}
@@ -125,11 +127,11 @@ class Chooser extends LitElement
<p class="control is-expanded">
<input class="file-name input" type="text"
name="filename" id="filename"
pattern="((file|http|https|s3):\/\/.*\.(warc|warc.gz|har|zip|wacz))|(googledrive:\/\/.+)"
pattern="((file|http|https|s3):\/\/.*\.(warc|warc.gz|zip|wacz))|(googledrive:\/\/.+)"
.value="${this.fileDisplayName}"
@input="${this.onInput}"
autocomplete="off"
placeholder="Enter a URL or click 'Choose File' to select a (WARC, HAR, WBN, or WACZ) archive source">
placeholder="Enter a URL or click 'Choose File' to select a WARC or WACZ archive source">
</p>
<div class="control">
<button type="submit" class="button is-hidden-mobile is-primary">Load</button>
+1 -1
View File
@@ -88,7 +88,7 @@ class GDrive extends LitElement
onLoad() {
this.scriptLoaded = true;
this.gauth('none', (response) => {
if (response.error === "immediate_failed") {
if (response.error) {
if (this.state !== "implicitonly") {
this.state = "trymanual";
}
+20
View File
@@ -1,6 +1,8 @@
import { LitElement, html, css } from 'lit-element';
import { wrapCss } from './misc';
import prettyBytes from 'pretty-bytes';
import { parseURLSchemeHostPath, initDBWorker } from './pageutils';
@@ -16,6 +18,9 @@ class Loader extends LitElement
this.state = "waiting";
this.loadInfo = null;
this.currentSize = 0;
this.totalSize = 0;
this.dbworker = initDBWorker();
}
@@ -26,6 +31,8 @@ class Loader extends LitElement
state: { type: String },
progress: { type: Number },
percent: { type: Number },
currentSize: { type: Number },
totalSize: { type: Number },
error: { type: String},
total: { type: Number },
status: { type: String },
@@ -48,6 +55,10 @@ class Loader extends LitElement
this.error = event.data.error;
this.state = "errored";
}
if (event.data.currentSize && event.data.totalSize) {
this.currentSize = event.data.currentSize;
this.totalSize = event.data.totalSize;
}
}
break;
@@ -69,6 +80,8 @@ class Loader extends LitElement
let sourceUrl = this.sourceUrl;
let source = null;
this.percent = this.currentSize = this.totalSize = 0;
// custom protocol handlers here...
try {
const {scheme, host, path} = parseURLSchemeHostPath(sourceUrl);
@@ -161,6 +174,10 @@ You can select a file to upload from the main page by clicking the \'Choose File
line-height: 1.5rem;
}
.loaded-prog {
margin-bottom: 1em;
}
.error {
white-space: pre-wrap;
margin-bottom: 2em;
@@ -197,6 +214,9 @@ You can select a file to upload from the main page by clicking the \'Choose File
<progress id="progress" class="progress is-primary is-large"
value="${this.percent}" max="100"></progress>
<label class="progress-label" for="progress">${this.percent}%</label>
${this.currentSize && this.totalSize ? html`
<p class="loaded-prog">Loaded <b>${prettyBytes(this.currentSize)}</b> of <b>${prettyBytes(this.totalSize)}</b></p>` : html``}
<button @click="${this.onCancel}" class="button is-danger">Cancel</button>
</div>`;
-4
View File
@@ -76,10 +76,6 @@ function getTS(iso) {
// ===========================================================================
async function sourceToId(url) {
try {
url = new URL(url, window.location.origin).href;
} catch(e) {}
const digest = await digestMessage(url, 'SHA-256');
const coll = "id-" + digest.slice(0, 12);
return {url, coll};
+15 -15
View File
File diff suppressed because one or more lines are too long
+22 -15
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -6006,7 +6006,7 @@ vm-browserify@^1.0.1:
"wabac@github:https://github.com/webrecorder/wabac.js#develop":
version "2.0.0"
resolved "https://codeload.github.com/webrecorder/wabac.js/tar.gz/43a612b488b665ca385512955cd007a162d6ce31"
resolved "https://codeload.github.com/webrecorder/wabac.js/tar.gz/ebb69d2e03d1fbbbd0e1e8a6650cf6d7eb41f68b"
dependencies:
brotli "github:foliojs/brotli.js"
fast-xml-parser "^3.15.1"