Compare commits

..

1 Commits

Author SHA1 Message Date
vorotamoroz 50247a80ea Deploy QR aggregator with GitHub Pages 2026-07-12 12:05:05 +00:00
4 changed files with 6 additions and 49 deletions
+4 -4
View File
@@ -1,4 +1,4 @@
import { Minimatch } from "minimatch";
import { minimatch } from "minimatch";
import { fsPromises as fs, path } from "@/apps/cli/node-compat";
/**
@@ -17,7 +17,7 @@ import { fsPromises as fs, path } from "@/apps/cli/node-compat";
* Missing files (`.livesync/ignore` or `.gitignore`) are silently skipped.
*/
export class IgnoreRules {
private patterns: Minimatch[] = [];
private patterns: string[] = [];
constructor(private vaultPath: string) {}
@@ -108,7 +108,7 @@ export class IgnoreRules {
`Remove it from .livesync/ignore or use a separate include/exclude file.`
);
}
this.patterns.push(new Minimatch(this._normalisePattern(raw), { dot: true }));
this.patterns.push(this._normalisePattern(raw));
}
/**
@@ -124,6 +124,6 @@ export class IgnoreRules {
}
// Normalise to forward slashes for minimatch.
const normalised = relativePath.replace(/\\/g, "/");
return this.patterns.some((pattern) => pattern.match(normalised));
return this.patterns.some((p) => minimatch(normalised, p, { dot: true }));
}
}
@@ -1,28 +1,7 @@
import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const minimatchStats = vi.hoisted(() => ({ constructions: 0 }));
vi.mock("minimatch", async (importOriginal) => {
const actual = await importOriginal<typeof import("minimatch")>();
class CountingMinimatch extends actual.Minimatch {
constructor(pattern: string, options?: import("minimatch").MinimatchOptions) {
super(pattern, options);
minimatchStats.constructions++;
}
}
return {
...actual,
Minimatch: CountingMinimatch,
minimatch: (path: string, pattern: string, options?: import("minimatch").MinimatchOptions) =>
new CountingMinimatch(pattern, options).match(path),
};
});
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { IgnoreRules } from "./IgnoreRules";
describe("IgnoreRules", () => {
@@ -40,10 +19,6 @@ describe("IgnoreRules", () => {
await fs.writeFile(path.join(ignoreDir, "ignore"), content, "utf-8");
}
beforeEach(() => {
minimatchStats.constructions = 0;
});
afterEach(async () => {
await Promise.all(tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true })));
});
@@ -80,20 +55,6 @@ describe("IgnoreRules", () => {
});
describe("shouldIgnore", () => {
it("compiles loaded patterns once", async () => {
const vaultPath = await createVault();
await writeIgnoreFile(vaultPath, "*.tmp\nbuild/\n");
const rules = new IgnoreRules(vaultPath);
await rules.load();
expect(rules.shouldIgnore("notes/readme.md")).toBe(false);
expect(rules.shouldIgnore("notes/scratch.tmp")).toBe(true);
expect(rules.shouldIgnore("build/output.js")).toBe(true);
expect(rules.shouldIgnore("other.md")).toBe(false);
expect(minimatchStats.constructions).toBe(2);
});
it("matches **/*.tmp against notes/scratch.tmp", async () => {
const vaultPath = await createVault();
await writeIgnoreFile(vaultPath, "*.tmp\n");
+1 -1
Submodule src/lib updated: ef1bdf0d07...1cb156d463
-4
View File
@@ -5,10 +5,6 @@ The head note of 0.25 is now in [updates_old.md](https://github.com/vrtmrz/obsid
## Unreleased
### Improved
- Improved vault scanning and CLI file filtering by reusing compiled ignore patterns, reducing processing overhead for vaults with many files or ignore rules (#1006, #1007, and #1008).
### Improved (CLI and Webapp)
- Rooted storage adapters now reject absolute, drive-qualified, backslash-separated, and traversal paths. They also prevent file writes, appends, and removal from targeting the configured root itself.