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
12 changes: 12 additions & 0 deletions src/addon-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,15 @@ export class Addon {
return this.parseAddonZod("hydrateFile", result);
}
}

export class DependencyInjectionAddonProvider {
private static _addon: Addon;

static get() {
if (DependencyInjectionAddonProvider._addon) return DependencyInjectionAddonProvider._addon;

DependencyInjectionAddonProvider._addon = new Addon();

return DependencyInjectionAddonProvider._addon;
}
}
8 changes: 4 additions & 4 deletions src/virtual-drive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "fs";
import path, { join, win32 } from "path";
import winston from "winston";

import { Addon } from "./addon-wrapper";
import { Addon, DependencyInjectionAddonProvider } from "./addon-wrapper";
import { createLogger } from "./logger";
import { QueueManager } from "./queue/queue-manager";
import { Callbacks } from "./types/callbacks.type";
Expand All @@ -25,7 +25,7 @@ class VirtualDrive {
addon: Addon;

constructor(syncRootPath: string, providerId: string, loggerPath: string) {
this.addon = new Addon();
this.addon = DependencyInjectionAddonProvider.get();
this.syncRootPath = this.convertToWindowsPath(syncRootPath);
loggerPath = this.convertToWindowsPath(loggerPath);
this.providerId = providerId;
Expand Down Expand Up @@ -164,8 +164,8 @@ class VirtualDrive {
return this.addon.unregisterSyncRoot({ providerId: this.providerId });
}

unRegisterSyncRootByProviderId({ providerId }: { providerId: string }) {
return this.addon.unregisterSyncRoot({ providerId });
static unRegisterSyncRootByProviderId({ providerId }: { providerId: string }) {
return DependencyInjectionAddonProvider.get().unregisterSyncRoot({ providerId });
}

watchAndWait(path: string, queueManager: QueueManager, loggerPath: string): void {
Expand Down