Lint & format

This commit is contained in:
Andras Schmelczer 2025-02-22 17:25:26 +00:00
parent 27423bf3cd
commit ca225a71be
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
17 changed files with 94 additions and 83 deletions

View file

@ -1,6 +1,6 @@
import { Logger } from "src/tracing/logger";
import { FileSystemOperations } from "./filesystem-operations";
import { RelativePath } from "src/persistence/database";
import type { Logger } from "src/tracing/logger";
import type { FileSystemOperations } from "./filesystem-operations";
import type { RelativePath } from "src/persistence/database";
import { isBinary, isFileTypeMergable, mergeText } from "sync_lib";
export class FileOperations {
@ -138,7 +138,7 @@ export class FileOperations {
await this.fs.rename(oldPath, newPath);
}
public isFileEligibleForSync(path: RelativePath): boolean {
public isFileEligibleForSync(_path: RelativePath): boolean {
return true;
// TODO: figure this out
// if (Platform.isDesktopApp) {

View file

@ -1,17 +1,17 @@
import { RelativePath } from "src/persistence/database";
import type { RelativePath } from "src/persistence/database";
export interface FileSystemOperations {
listAllFiles(): Promise<RelativePath[]>;
read(path: RelativePath): Promise<Uint8Array>;
write(path: RelativePath, content: Uint8Array): Promise<void>;
atomicUpdateText(
listAllFiles: () => Promise<RelativePath[]>;
read: (path: RelativePath) => Promise<Uint8Array>;
write: (path: RelativePath, content: Uint8Array) => Promise<void>;
atomicUpdateText: (
path: RelativePath,
updater: (currentContent: string) => string
): Promise<string>;
getFileSize(path: RelativePath): Promise<number>;
getModificationTime(path: RelativePath): Promise<Date>;
exists(path: RelativePath): Promise<boolean>;
createDirectory(path: RelativePath): Promise<void>;
delete(path: RelativePath): Promise<void>;
rename(oldPath: RelativePath, newPath: RelativePath): Promise<void>;
) => Promise<string>;
getFileSize: (path: RelativePath) => Promise<number>;
getModificationTime: (path: RelativePath) => Promise<Date>;
exists: (path: RelativePath) => Promise<boolean>;
createDirectory: (path: RelativePath) => Promise<void>;
delete: (path: RelativePath) => Promise<void>;
rename: (oldPath: RelativePath, newPath: RelativePath) => Promise<void>;
}

View file

@ -8,7 +8,7 @@ export interface DocumentMetadata {
hash: string;
}
import { Logger } from "src/tracing/logger";
import type { Logger } from "src/tracing/logger";
export interface StoredDatabase {
documents: Map<RelativePath, DocumentMetadata>;

View file

@ -1,4 +1,5 @@
import { Logger, LogLevel } from "src/tracing/logger";
import type { Logger } from "src/tracing/logger";
import { LogLevel } from "src/tracing/logger";
export interface SyncSettings {
remoteUri: string;

View file

@ -6,7 +6,7 @@ import type {
RelativePath,
VaultUpdateId
} from "../persistence/database";
import { Logger } from "src/tracing/logger";
import type { Logger } from "src/tracing/logger";
import { retriedFetchFactory } from "src/utils/retried-fetch";
import type { SyncSettings } from "dist/types";
import type { Settings } from "src/persistence/settings";

View file

@ -8,7 +8,7 @@ import { Settings } from "./persistence/settings";
import type { CheckConnectionResult } from "./services/sync-service";
import { SyncService } from "./services/sync-service";
import { Syncer } from "./sync-operations/syncer";
import { FileSystemOperations } from "./file-operations/filesystem-operations";
import type { FileSystemOperations } from "./file-operations/filesystem-operations";
import { FileOperations } from "./file-operations/file-operations";
export class SyncClient {
@ -39,6 +39,10 @@ export class SyncClient {
return this._logger;
}
public get documentCount(): number {
return this._database.getDocuments().size;
}
public static async create(
fs: FileSystemOperations,
persistence: PersistenceProvider
@ -124,10 +128,6 @@ export class SyncClient {
return client;
}
public get documentCount(): number {
return this._database.getDocuments().size;
}
public async checkConnection(): Promise<CheckConnectionResult> {
return this._syncService.checkConnection();
}

View file

@ -1,20 +1,16 @@
import type {
Database,
DocumentMetadata,
RelativePath
} from "../persistence/database";
import type { Database, RelativePath } from "../persistence/database";
import type { SyncService } from "src/services/sync-service";
import { Logger } from "src/tracing/logger";
import type { Logger } from "src/tracing/logger";
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 { EMPTY_HASH, hash } from "src/utils/hash";
import { hash } from "src/utils/hash";
import type { components } from "src/services/types";
import { deserialize } from "src/utils/deserialize";
import type { Settings } from "src/persistence/settings";
import { 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";
export class Syncer {
@ -75,7 +71,7 @@ export class Syncer {
);
}
public waitForSyncQueue(): Promise<void> {
public async waitForSyncQueue(): Promise<void> {
return this.syncQueue.onEmpty();
}

View file

@ -1,5 +1,5 @@
import type { RelativePath } from "src/persistence/database";
import { Logger } from "./logger";
import type { Logger } from "./logger";
export interface CommonHistoryEntry {
status: SyncStatus;
@ -47,7 +47,7 @@ export class SyncHistory {
error: 0
};
public constructor(private logger: Logger) {}
public constructor(private readonly logger: Logger) {}
public getEntries(): HistoryEntry[] {
return [...this.entries];

View file

@ -1,4 +1,4 @@
import { DocumentMetadata, RelativePath } from "src/persistence/database";
import type { DocumentMetadata, RelativePath } from "src/persistence/database";
import { EMPTY_HASH } from "./hash";
export function findMatchingFileBasedOnHash(

View file

@ -1,6 +1,6 @@
import * as fetchRetryFactory from "fetch-retry";
import type { RequestInitRetryParams } from "fetch-retry";
import { Logger } from "src/tracing/logger";
import type { Logger } from "src/tracing/logger";
const fetchWithRetry = fetchRetryFactory.default(fetch);
@ -15,7 +15,7 @@ function getUrlFromInput(input: RequestInfo | URL): string {
}
export function retriedFetchFactory(logger: Logger) {
return (
return async (
input: RequestInfo | URL,
init: RequestInitRetryParams<typeof fetch> = {}
): Promise<Response> => {