Files
Bitsy 35ffc86e46 Fix idle CPU drain from open path queries, general code cleanup
Fix
- An open window with a path query (term containing "/") re-ran the search
  over the whole index on every FSEvents update, keeping several cores busy
  while files changed. Index-driven refilters are now throttled to one per
  second, skipped while the window is closed, minimized or covered, and
  replayed once when it becomes visible again. Typing stays instant.
- Path terms no longer build and lowercase the full path of every record:
  the folded folder path is precomputed once per folder (interned like
  parentPath) and matched together with the folded name without allocating
  the joined string. Path-only queries are about 3x faster.

Cleanup
- Remove dead code: FSChange.isDir, FileWatcher.latestEventId,
  IndexState.record(atPath:), the never-set lastQuery preference,
  AccessManager.reset(), SearchField.onSubmit, an unreachable return.
- Merge duplicates: the two Settings size formatters become
  Formatters.sizeOrDash, the shellQuote wrapper is replaced by
  AdminShell.quote.
- Naming conventions: "in"-prefixed parameter names everywhere (delegate
  methods, binary helpers, initializers), camelCase impl helpers.
- Comment every function and type; fix stale comments.
- Debug and release builds are warning-free.
2026-10-02 09:29:18 +02:00

31 lines
1017 B
Swift

import Foundation
// Main is the binary's entry point. Routes by command-line arguments:
// --service run the headless indexer daemon
// install / uninstall / ... CLI service-control commands (see CLI.swift)
// anything else / no args launch the SwiftUI GUI
@main
struct Main {
// entry point: routes to the GUI, the headless service or the CLI
static func main() {
let vArgs = Array(CommandLine.arguments.dropFirst())
// No args: GUI mode. The Dock and Finder launch us with no args.
if vArgs.isEmpty {
AllofitApp.main()
return
}
// Headless indexer daemon, invoked by launchd's plist.
if vArgs.contains("--service") {
AllofitService.run()
}
// Anything else is a CLI command. Unknown commands print a hint
// to stderr and exit 1 rather than silently launching the GUI.
if !CLI.handle(arguments: vArgs) {
FileHandle.standardError.write(Data(
"Unknown command: \(vArgs.joined(separator: " "))\nUse --help for usage.\n".utf8
))
exit(1)
}
}
}