Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 1 addition & 6 deletions src/types/callbacks.type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type NapiCallbackFunction = (...args: any[]) => any;

Check warning on line 1 in src/types/callbacks.type.ts

View workflow job for this annotation

GitHub Actions / checks

Unexpected any. Specify a different type

Check warning on line 1 in src/types/callbacks.type.ts

View workflow job for this annotation

GitHub Actions / checks

Unexpected any. Specify a different type

export type FilePlaceholderIdPrefixType = "FILE:";

Expand Down Expand Up @@ -30,9 +30,4 @@
noneCallback?: NapiCallbackFunction;
};

export type ExtraCallbacks = {
notifyFileAddedCallback?: NapiCallbackFunction;
notifyMessageCallback?: NapiCallbackFunction;
};

export type Callbacks = InputSyncCallbacks & ExtraCallbacks;
export type Callbacks = InputSyncCallbacks;
15 changes: 4 additions & 11 deletions src/virtual-drive.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -180,15 +176,12 @@ class VirtualDrive {
async registerSyncRoot({
providerName,
providerVersion,
callbacks,
logoPath,
}: {
providerName: string;
providerVersion: string;
callbacks: Callbacks;
logoPath: string;
}): Promise<any> {
this.callbacks = callbacks;
this.logger.debug({ msg: "Registering sync root", syncRootPath: this.syncRootPath });
return this.addon.registerSyncRoot({
providerName,
Expand Down
6 changes: 1 addition & 5 deletions src/virtual-drive.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -160,14 +159,11 @@ describe("VirtualDrive", () => {
const providerName = "MyProvider";
const providerVersion = "1.0.0";
const logoPath = "C:\\iconPath";
const callbacks = mockDeep<Callbacks>();

// 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,
Expand Down
Loading