Merge branch 'main' into chore-release

This commit is contained in:
sigoden
2026-04-30 19:59:40 +08:00
2 changed files with 16 additions and 10 deletions
+11 -6
View File
@@ -260,12 +260,14 @@ class Uploader {
progress(event) {
const now = Date.now();
const speed = (event.loaded - this.uploaded) / (now - this.lastUptime) * 1000;
const elapsed = now - this.lastUptime;
if (elapsed < 300) return; // throttle update for safari
const speed = (event.loaded - this.uploaded) / elapsed * 1000;
const [speedValue, speedUnit] = formatFileSize(speed);
const speedText = `${speedValue} ${speedUnit}/s`;
const progress = formatPercent(((event.loaded + this.uploadOffset) / this.file.size) * 100);
const duration = formatDuration((event.total - event.loaded) / speed);
this.$uploadStatus.innerHTML = `<span style="width: 80px;">${speedText}</span><span>${progress} ${duration}</span>`;
this.$uploadStatus.innerHTML = `<span style="width: 80px;">${speedText}</span><span style="margin-left: 5px;">${progress} ${duration}</span>`;
this.uploaded = event.loaded;
this.lastUptime = now;
}
@@ -935,11 +937,14 @@ function formatFileSize(size) {
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
if (size == 0) return [0, "B"];
const i = parseInt(Math.floor(Math.log(size) / Math.log(1024)));
let ratio = 1;
if (i >= 3) {
ratio = 100;
const raw = size / Math.pow(1024, i);
let value;
if (i > 0 && raw < 999.95) {
value = Math.round(raw * 10) / 10;
} else {
value = Math.round(raw);
}
return [Math.round(size * ratio / Math.pow(1024, i), 2) / ratio, sizes[i]];
return [value, sizes[i]];
}
function formatDuration(seconds) {
+5 -4
View File
@@ -579,7 +579,7 @@ impl Server {
res: &mut Response,
) -> Result<()> {
let mut paths = vec![];
if exist {
if !head_only && exist {
paths = match self.list_dir(path, path, access_paths.clone()).await {
Ok(paths) => paths,
Err(_) => {
@@ -618,14 +618,15 @@ impl Server {
return self
.handle_ls_dir(path, true, query_params, head_only, user, access_paths, res)
.await;
} else {
}
if !head_only {
let path_buf = path.to_path_buf();
let hidden = Arc::new(self.args.hidden.to_vec());
let search = search.clone();
let access_paths = access_paths.clone();
let search_paths = tokio::spawn(collect_dir_entries(
access_paths,
access_paths.clone(),
self.running.clone(),
path_buf,
hidden,