Lint & format
This commit is contained in:
parent
0bf5f024ea
commit
f8dcd33d3e
2 changed files with 7 additions and 10 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { FileSystemOperations } from "dist/types";
|
import type { FileSystemOperations } from "dist/types";
|
||||||
import type { RelativePath } from "src/persistence/database";
|
import type { RelativePath } from "src/persistence/database";
|
||||||
|
|
||||||
export class FileNotFoundError extends Error {
|
export class FileNotFoundError extends Error {
|
||||||
|
|
@ -13,12 +13,12 @@ export class FileNotFoundError extends Error {
|
||||||
export class SafeFileSystemOperations implements FileSystemOperations {
|
export class SafeFileSystemOperations implements FileSystemOperations {
|
||||||
public constructor(private readonly fs: FileSystemOperations) {}
|
public constructor(private readonly fs: FileSystemOperations) {}
|
||||||
|
|
||||||
public listAllFiles(): Promise<RelativePath[]> {
|
public async listAllFiles(): Promise<RelativePath[]> {
|
||||||
return this.fs.listAllFiles();
|
return this.fs.listAllFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async read(path: RelativePath): Promise<Uint8Array> {
|
public async read(path: RelativePath): Promise<Uint8Array> {
|
||||||
return this.safeOperation(path, () => this.fs.read(path));
|
return this.safeOperation(path, async () => this.fs.read(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async write(path: RelativePath, content: Uint8Array): Promise<void> {
|
public async write(path: RelativePath, content: Uint8Array): Promise<void> {
|
||||||
|
|
@ -29,17 +29,17 @@ export class SafeFileSystemOperations implements FileSystemOperations {
|
||||||
path: RelativePath,
|
path: RelativePath,
|
||||||
updater: (currentContent: string) => string
|
updater: (currentContent: string) => string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return this.safeOperation(path, () =>
|
return this.safeOperation(path, async () =>
|
||||||
this.fs.atomicUpdateText(path, updater)
|
this.fs.atomicUpdateText(path, updater)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getFileSize(path: RelativePath): Promise<number> {
|
public async getFileSize(path: RelativePath): Promise<number> {
|
||||||
return this.safeOperation(path, () => this.fs.getFileSize(path));
|
return this.safeOperation(path, async () => this.fs.getFileSize(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getModificationTime(path: RelativePath): Promise<Date> {
|
public async getModificationTime(path: RelativePath): Promise<Date> {
|
||||||
return this.safeOperation(path, () =>
|
return this.safeOperation(path, async () =>
|
||||||
this.fs.getModificationTime(path)
|
this.fs.getModificationTime(path)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +60,7 @@ export class SafeFileSystemOperations implements FileSystemOperations {
|
||||||
oldPath: RelativePath,
|
oldPath: RelativePath,
|
||||||
newPath: RelativePath
|
newPath: RelativePath
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return this.safeOperation(oldPath, () =>
|
return this.safeOperation(oldPath, async () =>
|
||||||
this.fs.rename(oldPath, newPath)
|
this.fs.rename(oldPath, newPath)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,9 @@ import type { Database, RelativePath } from "../persistence/database";
|
||||||
import type { SyncService } from "src/services/sync-service";
|
import type { SyncService } from "src/services/sync-service";
|
||||||
import type { Logger } from "src/tracing/logger";
|
import type { Logger } from "src/tracing/logger";
|
||||||
import type { SyncHistory } from "src/tracing/sync-history";
|
import type { SyncHistory } from "src/tracing/sync-history";
|
||||||
import { SyncSource, SyncStatus, SyncType } from "src/tracing/sync-history";
|
|
||||||
import { unlockDocument, waitForDocumentLock } from "./document-lock";
|
|
||||||
import PQueue from "p-queue";
|
import PQueue from "p-queue";
|
||||||
import { hash } from "src/utils/hash";
|
import { hash } from "src/utils/hash";
|
||||||
import type { components } from "src/services/types";
|
import type { components } from "src/services/types";
|
||||||
import { deserialize } from "src/utils/deserialize";
|
|
||||||
import type { Settings } from "src/persistence/settings";
|
import type { Settings } from "src/persistence/settings";
|
||||||
import type { FileOperations } from "src/file-operations/file-operations";
|
import type { FileOperations } from "src/file-operations/file-operations";
|
||||||
import { findMatchingFileBasedOnHash } from "src/utils/find-matching-file-based-on-hash";
|
import { findMatchingFileBasedOnHash } from "src/utils/find-matching-file-based-on-hash";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue