This is a projection, not a development branch. The tree above was constructed from the internal source named below under a manifest that decides which paths may leave, then scanned as a whole tree rather than as a series of patches, and only then published. Public history starts here because the history before it was not admissible, and neither was the tree. What used to stand in this repository included a rescue copy of another machine, a directory of phone handoffs, deployment wired to one house, and a submodule pointing at a forge no stranger can reach. None of that was ever the product. It stays in the private forge, which is allowed to hold the whole working organism, and this is what was deliberately sent out instead. Three mechanisms produced this tree, in decreasing order of trust. A top-level path the manifest does not name never arrives at all, which is the one that catches directories nobody has thought of yet. Named internal files inside admitted roots are dropped. A short, reviewed table replaces deployment defaults that a public build must not carry -- an endpoint aimed at one LAN, a VPN profile belonging to one phone, packaging built from one checkout path. Everything after this commit is an ordinary publication with the same three trailers, so a force push stops being routine and starts meaning that something deliberate happened. The trailers bind the projection to its source without pretending the public SHA is the private one: same lineage, different tree, and the record says so. Source-Sha: 8f27b1e76a8fef560a336aba18e6990713ff1047 Policy-Sha: 6b261d2f3e6e1fb19874846ba4bb1dfe15565d25b8618c1c1afba0419c101d27 Tree-Digest: 18ec3563c5e5ef9a414993a9f6734b251ff9ed3cd56eebdd6cac01e45c6e3067
158 lines
3.9 KiB
QML
158 lines
3.9 KiB
QML
pragma Singleton
|
|
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import qs.modules.common
|
|
import qs.modules.common.functions
|
|
|
|
Singleton {
|
|
id: root
|
|
|
|
property var results: []
|
|
property string pendingQuery: ""
|
|
property string activeQuery: ""
|
|
property int searchId: 0
|
|
property bool running: false
|
|
|
|
function normalizePath(path) {
|
|
if (!path) return "";
|
|
let normalized = FileUtils.trimFileProtocol(String(path)).trim();
|
|
if (normalized.startsWith("~/")) {
|
|
normalized = FileUtils.trimFileProtocol(Directories.home) + normalized.slice(1);
|
|
}
|
|
if (normalized.endsWith("/")) {
|
|
normalized = normalized.slice(0, -1);
|
|
}
|
|
return normalized;
|
|
}
|
|
|
|
function isExcluded(path) {
|
|
if (Config.options.search.fileSearch.excludeHiddenDirs) {
|
|
// Match any hidden dir segment: "/.name/" or ending "/.name"
|
|
if (path.match(/\/\.[^/]+(\/|$)/)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
const exclude = Config.options.search.fileSearch.exclude;
|
|
if (!exclude || exclude.length === 0) return false;
|
|
for (let i = 0; i < exclude.length; i++) {
|
|
const needle = String(exclude[i]).trim();
|
|
if (needle.length === 0) continue;
|
|
if (path.includes(`/${needle}/`) || path.endsWith(`/${needle}`)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function isAllowedByPath(path) {
|
|
const paths = Config.options.search.fileSearch.paths;
|
|
if (!paths || paths.length === 0) return true;
|
|
for (let i = 0; i < paths.length; i++) {
|
|
const base = normalizePath(paths[i]);
|
|
if (!base) continue;
|
|
if (path === base || path.startsWith(base + "/")) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function shouldSearch(query) {
|
|
if (!Config.options.search.fileSearch.enable) return false;
|
|
if (!query || query.trim().length < 2) return false;
|
|
return true;
|
|
}
|
|
|
|
function reset() {
|
|
results = [];
|
|
activeQuery = "";
|
|
if (plocateProc.running) {
|
|
plocateProc.running = false;
|
|
}
|
|
}
|
|
|
|
function search(query) {
|
|
pendingQuery = String(query || "").trim();
|
|
if (!shouldSearch(pendingQuery)) {
|
|
reset();
|
|
return;
|
|
}
|
|
debounceTimer.restart();
|
|
}
|
|
|
|
Timer {
|
|
id: debounceTimer
|
|
interval: 200
|
|
repeat: false
|
|
onTriggered: {
|
|
root.runSearch(pendingQuery);
|
|
}
|
|
}
|
|
|
|
function runSearch(query) {
|
|
const trimmed = String(query || "").trim();
|
|
if (!shouldSearch(trimmed)) { reset(); return; }
|
|
if (plocateProc.running) plocateProc.running = false;
|
|
|
|
searchId += 1;
|
|
activeQuery = trimmed;
|
|
results = [];
|
|
|
|
const maxResults = Config.options.search.fileSearch.maxResults;
|
|
|
|
// Tag each line with d: or f: prefix
|
|
const command = [
|
|
"bash", "-c",
|
|
`plocate -i --basename --limit ${maxResults} '${trimmed}' | while IFS= read -r p; do [ -d "$p" ] && printf 'd:%s\n' "$p" || printf 'f:%s\n' "$p"; done`
|
|
];
|
|
|
|
plocateProc.runId = searchId;
|
|
plocateProc.accepted = 0;
|
|
plocateProc.command = command;
|
|
plocateProc.running = true;
|
|
root.running = true;
|
|
}
|
|
|
|
Process {
|
|
id: plocateProc
|
|
property int runId: 0
|
|
property int accepted: 0
|
|
|
|
stdout: SplitParser {
|
|
onRead: line => {
|
|
if (plocateProc.runId !== root.searchId) return;
|
|
const raw = String(line || "").trim();
|
|
if (!raw || raw.length < 3) return;
|
|
|
|
const isDir = raw.startsWith("d:");
|
|
const rawPath = raw.slice(2);
|
|
|
|
const normalized = root.normalizePath(rawPath);
|
|
if (!normalized) return;
|
|
if (!root.isAllowedByPath(normalized)) return;
|
|
if (root.isExcluded(normalized)) return;
|
|
if (plocateProc.accepted >= Config.options.search.fileSearch.maxResults) {
|
|
plocateProc.running = false;
|
|
return;
|
|
}
|
|
|
|
plocateProc.accepted += 1;
|
|
root.results = root.results.concat([{ path: normalized, isDir: isDir }]);
|
|
}
|
|
}
|
|
|
|
stderr: SplitParser {
|
|
onRead: line => {
|
|
if (plocateProc.runId !== root.searchId) return;
|
|
}
|
|
}
|
|
|
|
onExited: (exitCode, exitStatus) => {
|
|
if (plocateProc.runId !== root.searchId) return;
|
|
root.running = false;
|
|
}
|
|
}
|
|
}
|