diff --git a/examples/register.ts b/examples/register.ts index 7da2b52a..e09e85ab 100644 --- a/examples/register.ts +++ b/examples/register.ts @@ -27,10 +27,10 @@ const queueManager = new QueueManager({ handlers, persistPath: settings.queuePer drive.registerSyncRoot({ providerName: settings.driveName, providerVersion: settings.driveVersion, - callbacks, logoPath: settings.iconPath, }); -drive.connectSyncRoot(); + +drive.connectSyncRoot({ callbacks }); try { initInfoItems(); diff --git a/package.json b/package.json index a13024fd..7362fc49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@internxt/node-win", - "version": "1.0.11", + "version": "1.0.12", "description": "Drive desktop node addon", "main": "dist/index.ts", "types": "dist/index.d.ts", diff --git a/src/types/callbacks.type.ts b/src/types/callbacks.type.ts index 8b4f1160..1e99234a 100644 --- a/src/types/callbacks.type.ts +++ b/src/types/callbacks.type.ts @@ -30,9 +30,4 @@ export type InputSyncCallbacks = { noneCallback?: NapiCallbackFunction; }; -export type ExtraCallbacks = { - notifyFileAddedCallback?: NapiCallbackFunction; - notifyMessageCallback?: NapiCallbackFunction; -}; - -export type Callbacks = InputSyncCallbacks & ExtraCallbacks; +export type Callbacks = InputSyncCallbacks; diff --git a/src/virtual-drive.ts b/src/virtual-drive.ts index 4bab8dd8..8712c751 100644 --- a/src/virtual-drive.ts +++ b/src/virtual-drive.ts @@ -1,5 +1,5 @@ import fs from "fs"; -import path, { join, win32 } from "path"; +import path, { join, posix, win32 } from "path"; import { Addon, DependencyInjectionAddonProvider } from "./addon-wrapper"; import { TLogger } from "./logger"; @@ -51,7 +51,7 @@ class VirtualDrive { } convertToWindowsPath({ path }: { path: string }) { - return path.replaceAll("/", win32.sep); + return path.replaceAll(posix.sep, win32.sep); } fixPath(path: string) { @@ -89,12 +89,8 @@ class VirtualDrive { return this.addon.deleteFileSyncRoot({ path: this.fixPath(path) }); } - connectSyncRoot() { - if (this.callbacks === undefined) { - throw new Error("Callbacks are not defined"); - } - - const connectionKey = this.addon.connectSyncRoot({ callbacks: this.callbacks }); + connectSyncRoot({ callbacks }: { callbacks: Callbacks }) { + const connectionKey = this.addon.connectSyncRoot({ callbacks }); this.logger.debug({ msg: "connectSyncRoot", connectionKey }); return connectionKey; @@ -180,15 +176,12 @@ class VirtualDrive { async registerSyncRoot({ providerName, providerVersion, - callbacks, logoPath, }: { providerName: string; providerVersion: string; - callbacks: Callbacks; logoPath: string; }): Promise { - this.callbacks = callbacks; this.logger.debug({ msg: "Registering sync root", syncRootPath: this.syncRootPath }); return this.addon.registerSyncRoot({ providerName, diff --git a/src/virtual-drive.unit.test.ts b/src/virtual-drive.unit.test.ts index dd676f0b..bc19b158 100644 --- a/src/virtual-drive.unit.test.ts +++ b/src/virtual-drive.unit.test.ts @@ -6,7 +6,6 @@ import { mockDeep } from "vitest-mock-extended"; import { addon } from "@/addon"; import { TLogger } from "./logger"; -import { Callbacks } from "./types/callbacks.type"; import VirtualDrive from "./virtual-drive"; vi.mock(import("fs")); @@ -160,14 +159,11 @@ describe("VirtualDrive", () => { const providerName = "MyProvider"; const providerVersion = "1.0.0"; const logoPath = "C:\\iconPath"; - const callbacks = mockDeep(); // Act - expect(drive.callbacks).toBe(undefined); - await drive.registerSyncRoot({ providerName, providerVersion, callbacks, logoPath }); + await drive.registerSyncRoot({ providerName, providerVersion, logoPath }); // Assert - expect(drive.callbacks).not.toBe(undefined); expect(addon.registerSyncRoot).toHaveBeenCalledWith( syncRootPath, providerName,