Spaces:
Sleeping
Sleeping
coyotte508
commited on
Commit
·
a5fa4af
1
Parent(s):
723c3de
Also check local file
Browse files- src/lib/check-dduf.ts +2 -2
- src/routes/+page.svelte +21 -2
src/lib/check-dduf.ts
CHANGED
@@ -2,10 +2,10 @@ import { checkFilename } from './check-filename';
|
|
2 |
import { WebBlob } from './WebBlob';
|
3 |
|
4 |
export async function* checkDduf(
|
5 |
-
url: string,
|
6 |
opts?: { log?: (x: string) => void }
|
7 |
): AsyncGenerator<{ type: 'file'; name: string; size: number; fileHeaderOffset: number }> {
|
8 |
-
const blob = await WebBlob.create(new URL(url));
|
9 |
|
10 |
opts?.log?.('File size: ' + blob.size);
|
11 |
|
|
|
2 |
import { WebBlob } from './WebBlob';
|
3 |
|
4 |
export async function* checkDduf(
|
5 |
+
url: Blob | string,
|
6 |
opts?: { log?: (x: string) => void }
|
7 |
): AsyncGenerator<{ type: 'file'; name: string; size: number; fileHeaderOffset: number }> {
|
8 |
+
const blob = url instanceof Blob ? url : await WebBlob.create(new URL(url));
|
9 |
|
10 |
opts?.log?.('File size: ' + blob.size);
|
11 |
|
src/routes/+page.svelte
CHANGED
@@ -2,7 +2,10 @@
|
|
2 |
import { checkDduf } from '$lib/check-dduf';
|
3 |
import { tick } from 'svelte';
|
4 |
|
5 |
-
let url = $state(
|
|
|
|
|
|
|
6 |
let output = $state('');
|
7 |
let error = $state('');
|
8 |
let files: Array<{ position: number; size: number; name: string }> = $state([]);
|
@@ -14,7 +17,7 @@
|
|
14 |
files = [];
|
15 |
|
16 |
try {
|
17 |
-
for await (const file of checkDduf(url, {
|
18 |
log: (s) => {
|
19 |
output += '\n' + s;
|
20 |
tick().then(() => {
|
@@ -48,6 +51,22 @@
|
|
48 |
name="url"
|
49 |
placeholder="https://huggingface.co/spaces/coyotte508/dduf-check/resolve/main/file.dduf"
|
50 |
bind:value={url}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
class="w-full rounded-md border border-gray-300 p-2"
|
52 |
/>
|
53 |
</label>
|
|
|
2 |
import { checkDduf } from '$lib/check-dduf';
|
3 |
import { tick } from 'svelte';
|
4 |
|
5 |
+
let url = $state(
|
6 |
+
'https://huggingface.co/DDUF/Flux.1-Dev-Tnf4-TE2NF4/resolve/main/Flux.1-Dev-Tnf4-TE2NF4.dduf'
|
7 |
+
);
|
8 |
+
let blob = $state<Blob | null>(null);
|
9 |
let output = $state('');
|
10 |
let error = $state('');
|
11 |
let files: Array<{ position: number; size: number; name: string }> = $state([]);
|
|
|
17 |
files = [];
|
18 |
|
19 |
try {
|
20 |
+
for await (const file of checkDduf(blob ?? url, {
|
21 |
log: (s) => {
|
22 |
output += '\n' + s;
|
23 |
tick().then(() => {
|
|
|
51 |
name="url"
|
52 |
placeholder="https://huggingface.co/spaces/coyotte508/dduf-check/resolve/main/file.dduf"
|
53 |
bind:value={url}
|
54 |
+
class="w-full rounded-md border border-gray-300 p-2 disabled:opacity-50"
|
55 |
+
disabled={blob !== null}
|
56 |
+
/>
|
57 |
+
</label>
|
58 |
+
|
59 |
+
or
|
60 |
+
|
61 |
+
<label class="flex flex-col gap-2">
|
62 |
+
DDUF File
|
63 |
+
<input
|
64 |
+
type="file"
|
65 |
+
name="file"
|
66 |
+
accept=".dduf"
|
67 |
+
onchange={async (event) => {
|
68 |
+
blob = (event.target as HTMLInputElement).files?.[0] ?? null;
|
69 |
+
}}
|
70 |
class="w-full rounded-md border border-gray-300 p-2"
|
71 |
/>
|
72 |
</label>
|