Files
Allofit/Package.swift
Bitsy 147c4a9353 Fix memory blow-up on relaunch, Everything-style search, index correctness
Memory / relaunch
- FSEvents replay after a relaunch no longer copies the whole index per
  changed file: allRecords is no longer @Published (each element mutation
  emitted the full array and a buffering subscriber kept every copy alive,
  reaching 10+ GB). Changes are coalesced, stat'ed off-main and merged once.
- Save the cache when the history replay finishes and on quit, and save the
  event id actually merged, so the next launch doesn't replay days again.
- Views (App scene, ContentView, PreviewPane) no longer observe AppModel, so
  index updates don't re-render the table or reload the Quick Look preview.
- Break retain cycles in the FSEvents watcher callbacks.

Search (Everything syntax)
- Space = AND, | = OR, ! = NOT, quotes, ext:, file:, folder:.
- Terms with / match the full path; path wildcards are folder-aware
  (* within a folder name, ** across folders), e.g.
  "some/folder/**/path" IMG_????.heic
- Byte-level matching (memmem / native glob) instead of NSRegularExpression,
  parallel filter, top-N selection instead of a full sort, total match count
  in the status bar, near-instant typing debounce.

Index correctness
- New IndexState shared by the GUI and the service: stable path-derived ids,
  O(1) swap removal, folder removal drops its subtree (no ghost entries after
  moving a folder to the Trash), folders moved/renamed in are rescanned,
  parent-must-be-indexed rule matching the walker (hidden/package content).
- Unicode-normalized path ids (no duplicates for accented names).
- Reconcile on load and on settings change: prune removed roots, exclusions
  and orphans; scan new roots; rescan when the saved event id is unusable.
- Service resumes from its cache instead of rescanning everything on start.
- Shared parent-path strings, cheaper exclusion checks, deduped roots.

Tests
- Swift Testing target for the search syntax, index rules, top-N selection
  and cache round trip; run in CI.
2026-10-01 17:45:44 +02:00

42 lines
1.2 KiB
Swift

// swift-tools-version: 6.0
import PackageDescription
// Allofit is a macOS file search utility inspired by voidtools "Everything".
// It builds an in-memory index of filesystem entries and offers instant
// wildcard search, real-time updates via FSEvents, drag-and-drop and Quick Look.
//
// Deployment target is macOS 15 (Sequoia) so users on 15 and 26 can both run
// it. Apple skipped 16-25 with the year-aligned renumbering, so .v15 is "one
// macOS version below 26".
//
// Language mode stays at Swift 5: we compile with the Swift 6 toolchain to
// get the latest SDK and language features, but skip the strict-concurrency
// runtime checks which were turning into hard traps on launch.
let package = Package(
name: "Allofit",
platforms: [
.macOS(.v15)
],
products: [
.executable(name: "Allofit", targets: ["Allofit"])
],
targets: [
.executableTarget(
name: "Allofit",
path: "sources",
swiftSettings: [
.swiftLanguageMode(.v5)
]
),
// unit tests for the search syntax, index rules and cache format
.testTarget(
name: "AllofitTests",
dependencies: ["Allofit"],
path: "tests",
swiftSettings: [
.swiftLanguageMode(.v5)
]
)
]
)