feat: polish workspace transfers and verify Craft server file workflows
This commit is contained in:
1 parent
7fd7ae6733
commit
c209f1effc
49 files changed
+1459
-670
No files matched your search
@@ -0,0 +1,20 @@
|
||||
export function transferProgress(sent: number, total: number) {
|
||||
return total > 0 && Number.isFinite(sent)
|
||||
? Math.max(0, Math.min(100, Math.round((sent / total) * 100)))
|
||||
: 0;
|
||||
}
|
||||
export function transferSample(
|
||||
previous: { bytes: number; time: number; rate: number },
|
||||
bytes: number,
|
||||
time: number
|
||||
) {
|
||||
if (bytes < previous.bytes || bytes === 0) return { bytes, time, rate: 0 };
|
||||
const elapsed = (time - previous.time) / 1000;
|
||||
if (elapsed < 0.25) return previous;
|
||||
const current = (bytes - previous.bytes) / elapsed;
|
||||
return {
|
||||
bytes,
|
||||
time,
|
||||
rate: previous.rate ? current * 0.4 + previous.rate * 0.6 : current,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user