scan.zig: Revamp output API, reduce buffering a bit, re-add UI

New output API takes over (most of) the buffering responsibilites from
the scanning code, simplifying that code and allowing for a few minor
optimizations, such as not buffering at all when scanning into RAM and
buffering directly into JSON strings when exporting.

This is mostly yak shaving, hopefully allowing for further performance
improvements to be implemented later. The new API could also be extended
to support parallel scanning of disjoint trees, in case current approach
isn't working out too well.

Also re-added the progress UI and improved propagating read errors.
A visible side effect of the new API is that the progress UI now
displays the most recent directory being scanned rather than individual
files. Not a big loss, I hope?
This commit is contained in:
Yorhel 2022-02-02 10:24:48 +01:00
parent c27dca1fba
commit fe2340876d
3 changed files with 632 additions and 596 deletions

View file

@ -848,10 +848,8 @@ pub fn keyInput(ch: i32) void {
'r' => { 'r' => {
if (!main.config.can_refresh.?) if (!main.config.can_refresh.?)
message = "Directory refresh feature disabled." message = "Directory refresh feature disabled."
else { else
main.state = .refresh; main.state = .refresh;
scan.setupRefresh(dir_parent);
}
}, },
'b' => { 'b' => {
if (!main.config.can_shell.?) if (!main.config.can_shell.?)

View file

@ -428,7 +428,7 @@ pub fn main() void {
} }
} }
var scan_dir: ?[]const u8 = null; var scan_dir: ?[:0]const u8 = null;
var import_file: ?[:0]const u8 = null; var import_file: ?[:0]const u8 = null;
var export_file: ?[:0]const u8 = null; var export_file: ?[:0]const u8 = null;
{ {
@ -499,7 +499,7 @@ pub fn main() void {
while (true) { while (true) {
switch (state) { switch (state) {
.refresh => { .refresh => {
scan.scan(); scan.refresh(browser.dir_parent);
state = .browse; state = .browse;
browser.loadDir(null); browser.loadDir(null);
}, },

File diff suppressed because it is too large Load diff