Use new api

This commit is contained in:
Andras Schmelczer 2024-12-14 15:02:26 +00:00
parent 4e2a7501f4
commit f803ec0da5
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -4,9 +4,7 @@ import { Logger } from "src/logger";
import { SyncServer } from "src/services/sync_service";
import { Database } from "src/database/database";
import { syncLocallyDeletedFile } from "src/sync-functions/sync-locally-deleted-file";
import { syncLocallyRenamedFile } from "src/sync-functions/sync-locally-renamed-file";
import { syncLocallyUpdatedFile } from "src/sync-functions/sync-locally-updated-file";
import { syncNewLocalFile } from "src/sync-functions/sync-new-local-file";
export class SyncEventHandler implements FileEventHandler {
constructor(private database: Database, private syncServer: SyncServer) {}
@ -14,7 +12,11 @@ export class SyncEventHandler implements FileEventHandler {
async onCreate(file: TAbstractFile): Promise<void> {
if (file instanceof TFile) {
Logger.getInstance().info(`File created: ${file.path}`);
syncNewLocalFile(this.database, this.syncServer, file);
syncLocallyUpdatedFile({
database: this.database,
syncServer: this.syncServer,
file,
});
} else {
Logger.getInstance().info(`Folder created: ${file.path}, ignored`);
}
@ -33,12 +35,12 @@ export class SyncEventHandler implements FileEventHandler {
Logger.getInstance().info(`File renamed: ${oldPath} -> ${file.path}`);
if (file instanceof TFile) {
syncLocallyRenamedFile(
this.database,
this.syncServer,
syncLocallyUpdatedFile({
database: this.database,
syncServer: this.syncServer,
file,
oldPath
);
oldPath,
});
} else {
Logger.getInstance().info(
`Folder renamed: ${oldPath} -> ${file.path}, ignored`
@ -50,7 +52,11 @@ export class SyncEventHandler implements FileEventHandler {
Logger.getInstance().info(`File modified: ${file.path}`);
if (file instanceof TFile) {
syncLocallyUpdatedFile(this.database, this.syncServer, file);
syncLocallyUpdatedFile({
database: this.database,
syncServer: this.syncServer,
file,
});
} else {
Logger.getInstance().info(`Folder modified: ${file.path}, ignored`);
}