A progress sample that missed a partial file showed 0 B while hf kept downloading. Walk the download cache tolerating vanished folders and never let a file's progress go backwards within a run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
22a54f731d
commit
4f05ee165c
6 files changed
+80
-18
No files matched your search
@@ -20,11 +20,13 @@ import { escapeGlob } from "@/lib/selection";
|
||||
import {
|
||||
bytesOnDisk,
|
||||
type ExpectedFile,
|
||||
type FileProgress,
|
||||
listIncomplete,
|
||||
fileSize,
|
||||
modelDir,
|
||||
removeLocalFile,
|
||||
removeStaleIncomplete,
|
||||
steadyProgress,
|
||||
xetFor,
|
||||
} from "./hf-layout";
|
||||
import { JobLog } from "./job-log";
|
||||
@@ -318,11 +320,13 @@ export class DownloadRunner implements Runner {
|
||||
// Progress from bytes on disk, written to the DB once per second.
|
||||
const speed = new SpeedMeter();
|
||||
let busy = false;
|
||||
let last: FileProgress[] | null = null;
|
||||
const timer = setInterval(async () => {
|
||||
if (busy) return;
|
||||
busy = true;
|
||||
try {
|
||||
const progress = await this.sample(dir, expected);
|
||||
const progress = steadyProgress(last, await this.sample(dir, expected));
|
||||
last = progress;
|
||||
const doneBytes = progress.reduce((s, p) => s + p.done, 0);
|
||||
speed.add(Date.now(), doneBytes);
|
||||
await this.writeProgress(progress, doneBytes, speed);
|
||||
|
||||
Reference in new issue
Block a user