mirror of
https://github.com/upa/mscp.git
synced 2026-02-14 00:54:43 +08:00
fix stat output
This commit is contained in:
@@ -724,8 +724,10 @@ int chunk_copy(struct chunk *c, sftp_session sftp, size_t buf_sz, size_t *counte
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (refcnt_dec(&f->refcnt) == 0)
|
||||
if (refcnt_dec(&f->refcnt) == 0) {
|
||||
f->state = FILE_STATE_DONE;
|
||||
pr("copy done: %s\n", f->path);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
27
src/main.c
27
src/main.c
@@ -422,31 +422,35 @@ void *sscp_monitor_thread(void *arg)
|
||||
total += f->size;
|
||||
}
|
||||
total_round = total;
|
||||
for (byte_tu = 0; total_round > 1000 && byte_tu < 5; byte_tu++)
|
||||
for (byte_tu = 0; total_round > 1000 && byte_tu < 4; byte_tu++)
|
||||
total_round /= 1024;
|
||||
|
||||
while (1) {
|
||||
|
||||
gettimeofday(&b, NULL);
|
||||
sleep(1);
|
||||
|
||||
all_done = true;
|
||||
last = 0;
|
||||
done = 0;
|
||||
|
||||
for (n = 0; n < nr_threads; n++) {
|
||||
t = &threads[n];
|
||||
last += t->done;
|
||||
}
|
||||
gettimeofday(&b, NULL);
|
||||
|
||||
sleep(1);
|
||||
|
||||
for (n = 0; n < nr_threads; n++) {
|
||||
t = &threads[n];
|
||||
done += t->done;
|
||||
if (!t->finished)
|
||||
all_done = false;
|
||||
}
|
||||
|
||||
gettimeofday(&a, NULL);
|
||||
|
||||
percent = floor(((double)(done) / (double)total) * 100);
|
||||
for (byte_du = 0; done > 1000 && byte_du < 5; byte_du++) done /= 1024;
|
||||
|
||||
bps = calculate_bps(done - last, &b, &a);
|
||||
for (bps_u = 0; bps > 1000 && bps_u < 4; bps_u++) bps /= 1000;
|
||||
for (bps_u = 0; bps > 1000 && bps_u < 3; bps_u++) bps /= 1000;
|
||||
|
||||
percent = floor(((double)(done) / (double)total) * 100);
|
||||
for (byte_du = 0; done > 1000 && byte_du < 4; byte_du++) done /= 1024;
|
||||
|
||||
printf("%d%% (%lu%s/%lu%s) %.2f %s\n",
|
||||
percent,
|
||||
@@ -455,9 +459,6 @@ void *sscp_monitor_thread(void *arg)
|
||||
|
||||
if (all_done || total == done)
|
||||
break;
|
||||
|
||||
last = done;
|
||||
b = a;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user