Use new api
This commit is contained in:
parent
4e2a7501f4
commit
f803ec0da5
1 changed files with 15 additions and 9 deletions
|
|
@ -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`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue