mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-12 17:08:39 -09:00
Add progress indicator to hardlink counting + fix import/mem UI updating
This commit is contained in:
parent
0a6bcee32b
commit
87d336baeb
4 changed files with 31 additions and 6 deletions
|
|
@ -456,7 +456,7 @@ fn item(ctx: *Ctx, parent: ?*sink.Dir, dev: u64) void {
|
|||
parent.?.addStat(ctx.sink, name, &ctx.stat);
|
||||
}
|
||||
|
||||
if ((ctx.sink.files_seen.load(.monotonic) & 1024) == 0)
|
||||
if ((ctx.sink.files_seen.load(.monotonic) & 65) == 0)
|
||||
main.handleEvent(false, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ const Ctx = struct {
|
|||
|
||||
|
||||
fn rec(ctx: *Ctx, dir: *sink.Dir, entry: *model.Entry) void {
|
||||
if ((ctx.sink.files_seen.load(.monotonic) & 1024) == 0)
|
||||
if ((ctx.sink.files_seen.load(.monotonic) & 65) == 0)
|
||||
main.handleEvent(false, false);
|
||||
|
||||
ctx.stat = toStat(entry);
|
||||
|
|
|
|||
|
|
@ -417,13 +417,29 @@ pub const inodes = struct {
|
|||
}
|
||||
}
|
||||
|
||||
// counters to track progress for addAllStats()
|
||||
pub var add_total: usize = 0;
|
||||
pub var add_done: usize = 0;
|
||||
|
||||
pub fn addAllStats() void {
|
||||
if (uncounted_full) {
|
||||
add_total = map.count();
|
||||
add_done = 0;
|
||||
var it = map.keyIterator();
|
||||
while (it.next()) |e| setStats(e.*, true);
|
||||
while (it.next()) |e| {
|
||||
setStats(e.*, true);
|
||||
add_done += 1;
|
||||
if ((add_done & 65) == 0) main.handleEvent(false, false);
|
||||
}
|
||||
} else {
|
||||
add_total = uncounted.count();
|
||||
add_done = 0;
|
||||
var it = uncounted.keyIterator();
|
||||
while (it.next()) |u| if (map.getKey(u.*)) |e| setStats(e, true);
|
||||
while (it.next()) |u| {
|
||||
if (map.getKey(u.*)) |e| setStats(e, true);
|
||||
add_done += 1;
|
||||
if ((add_done & 65) == 0) main.handleEvent(false, false);
|
||||
}
|
||||
}
|
||||
uncounted_full = false;
|
||||
if (uncounted.count() > 0)
|
||||
|
|
|
|||
13
src/sink.zig
13
src/sink.zig
|
|
@ -295,7 +295,11 @@ fn drawConsole() void {
|
|||
}
|
||||
|
||||
if (global.state == .hlcnt) {
|
||||
wr.writeAll("Counting hardlinks...\n") catch {};
|
||||
wr.writeAll("Counting hardlinks...") catch {};
|
||||
if (model.inodes.add_total > 0)
|
||||
wr.print(" {} / {}", .{ model.inodes.add_done, model.inodes.add_total }) catch {};
|
||||
wr.writeByte('\n') catch {};
|
||||
st.lines_written += 1;
|
||||
|
||||
} else if (global.state == .running) {
|
||||
var bytes: u64 = 0;
|
||||
|
|
@ -445,7 +449,12 @@ pub fn draw() void {
|
|||
.hlcnt => {
|
||||
const box = ui.Box.create(4, ui.cols -| 5, "Finalizing");
|
||||
box.move(2, 2);
|
||||
ui.addstr("Counting hardlinks...");
|
||||
ui.addstr("Counting hardlinks... ");
|
||||
if (model.inodes.add_total > 0) {
|
||||
ui.addnum(.default, model.inodes.add_done);
|
||||
ui.addstr(" / ");
|
||||
ui.addnum(.default, model.inodes.add_total);
|
||||
}
|
||||
},
|
||||
.running => drawProgress(),
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue