Refactored: changed the implementation from using overrides to injecting an adapter.

This commit is contained in:
vorotamoroz
2026-03-02 09:06:23 +00:00
parent 28e06a21e4
commit f3e83d4045
19 changed files with 430 additions and 385 deletions

View File

@@ -1,7 +1,7 @@
import { unique } from "octagonal-wheels/collection";
import { throttle } from "octagonal-wheels/function";
import { EVENT_ON_UNRESOLVED_ERROR, eventHub } from "../../common/events.ts";
import { BASE_IS_NEW, compareFileFreshness, EVEN, isValidPath, TARGET_IS_NEW } from "../../common/utils.ts";
import { BASE_IS_NEW, EVEN, isValidPath, TARGET_IS_NEW } from "../../common/utils.ts";
import {
type FilePathWithPrefixLC,
type FilePathWithPrefix,
@@ -308,7 +308,7 @@ export class ModuleInitializerFile extends AbstractModule {
}
}
const compareResult = compareFileFreshness(file, doc);
const compareResult = this.services.path.compareFileFreshness(file, doc);
switch (compareResult) {
case BASE_IS_NEW:
if (!this.services.vault.isFileSizeTooLarge(file.stat.size)) {

View File

@@ -1,7 +1,40 @@
import type { ObsidianServiceContext } from "@lib/services/implements/obsidian/ObsidianServiceContext";
import { normalizePath } from "@/deps";
import { PathService } from "@/lib/src/services/base/PathService";
import {
type BASE_IS_NEW,
type TARGET_IS_NEW,
type EVEN,
markChangesAreSame,
unmarkChanges,
compareFileFreshness,
isMarkedAsSameChanges,
} from "@/common/utils";
import type { UXFileInfo, AnyEntry, UXFileInfoStub, FilePathWithPrefix } from "@/lib/src/common/types";
export class ObsidianPathService extends PathService<ObsidianServiceContext> {
override markChangesAreSame(
old: UXFileInfo | AnyEntry | FilePathWithPrefix,
newMtime: number,
oldMtime: number
): boolean | undefined {
return markChangesAreSame(old, newMtime, oldMtime);
}
override unmarkChanges(file: AnyEntry | FilePathWithPrefix | UXFileInfoStub): void {
return unmarkChanges(file);
}
override compareFileFreshness(
baseFile: UXFileInfoStub | AnyEntry | undefined,
checkTarget: UXFileInfo | AnyEntry | undefined
): typeof BASE_IS_NEW | typeof TARGET_IS_NEW | typeof EVEN {
return compareFileFreshness(baseFile, checkTarget);
}
override isMarkedAsSameChanges(
file: UXFileInfoStub | AnyEntry | FilePathWithPrefix,
mtimes: number[]
): undefined | typeof EVEN {
return isMarkedAsSameChanges(file, mtimes);
}
protected normalizePath(path: string): string {
return normalizePath(path);
}