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
2 changes: 1 addition & 1 deletion examples/callbacks/notify-delete.callback.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { logger } from "@/logger";

export const onDeleteCallback = (fileId: string, callback: (response: boolean) => void) => {
export const notifyDeleteCallback = (fileId: string, callback: (response: boolean) => void) => {
logger.info({ event: "onDelete", fileId });
callback(true);
};
2 changes: 1 addition & 1 deletion examples/callbacks/notify-fetch-data.callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sleep } from "@/utils";

type CallbackResponse = (data: boolean, path: string, errorHandler?: () => void) => Promise<{ finished: boolean; progress: number }>;

export const onFetchDataCallback = async (id: string, callback: CallbackResponse) => {
export const fetchDataCallback = async (id: string, callback: CallbackResponse) => {
const path = await getInfoItem(id);

let finish = false;
Expand Down
7 changes: 0 additions & 7 deletions examples/config.json

This file was deleted.

91 changes: 0 additions & 91 deletions examples/queueManager.ts

This file was deleted.

30 changes: 17 additions & 13 deletions examples/register.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { QueueItem, VirtualDrive } from "src";

import { logger } from "@/logger";
import { QueueManager } from "@/queue/queue-manager";
import { QueueItem } from "@/queue/queueManager";
import VirtualDrive from "@/virtual-drive";

import { onCancelFetchDataCallback, onMessageCallback, onRenameCallbackWithCallback } from "./callbacks";
import { onDeleteCallback } from "./callbacks/notify-delete.callback";
import { onFetchDataCallback } from "./callbacks/notify-fetch-data.callback";
import { notifyDeleteCallback } from "./callbacks/notify-delete.callback";
import { fetchDataCallback } from "./callbacks/notify-fetch-data.callback";
import { drive } from "./drive";
import { addInfoItem, initInfoItems } from "./info-items-manager";
import { QueueManager } from "./queueManager";
import settings from "./settings";
import { generateRandomFilesAndFolders } from "./utils/generate-random-file-tree";

Expand All @@ -18,21 +18,20 @@ drive.registerSyncRoot(
settings.driveVersion,
"{12345678-1234-1234-1234-123456789012}",
{
notifyDeleteCallback: onDeleteCallback,
notifyDeleteCallback,
notifyRenameCallback: onRenameCallbackWithCallback,
fetchDataCallback: onFetchDataCallback,
fetchDataCallback,
cancelFetchDataCallback: onCancelFetchDataCallback,
notifyMessageCallback: onMessageCallback,
},
settings.defaultIconPath,
settings.iconPath,
);

const handleAdd = async (task: QueueItem) => {
try {
logger.info({ fn: "handleAdd", path: task.path });
const id = await addInfoItem(task.path);
drive.convertToPlaceholder(task.path, id);
// await drive.updateSyncStatus(task.path, task.isFolder, true);
} catch (error) {
logger.error(error, "handleAdd");
}
Expand Down Expand Up @@ -69,12 +68,19 @@ const handleChangeSize = async (task: QueueItem) => {
}
};

const queueManager = new QueueManager({
const handlers = {
handleAdd,
handleHydrate,
handleDehydrate,
handleChangeSize,
});
};

const notify = {
onTaskSuccess: async () => logger.info({ fn: "onTaskSuccess" }),
onTaskProcessing: async () => logger.info({ fn: "onTaskProcessing" }),
};

const queueManager = new QueueManager(handlers, notify, settings.queuePersistPath);

drive.connectSyncRoot();

Expand All @@ -98,5 +104,3 @@ const fileGenerationOptions = {
console.log("[EXAMPLE] error: " + error);
}
})();

export default drive;
3 changes: 2 additions & 1 deletion examples/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const settings = {
driveName: "Internxt",
driveVersion: "2.0.4",
syncRootPath: join(TMP_PATH, "sync-root"),
iconPath: join(cwd(), "assets", "icon.ico"),
defaultLogPath: join(TMP_PATH, "drive.log"),
defaultIconPath: join(cwd(), "assets", "icon.ico"),
watcherLogPath: join(TMP_PATH, "watcher.log"),
queuePersistPath: join(TMP_PATH, "queue-manager.json"),
};

export default settings;
2 changes: 1 addition & 1 deletion examples/utils/generate-random-file-tree.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VirtualDrive } from 'src';
import VirtualDrive from '@/virtual-drive';
import { v4 as uuidv4 } from 'uuid';

interface GenerateOptions {
Expand Down
18 changes: 3 additions & 15 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
import { QueueManager } from "./src/queue/queue-manager";
import { IQueueManager, QueueItem, typeQueue, HandleAction, HandleActions } from "./src/queue/queueManager";
import VirtualDrive from "./src/virtual-drive";
import {
IQueueManager,
QueueItem,
typeQueue,
HandleAction,
HandleActions,
} from "./src/queue/queueManager";

export {
VirtualDrive,
QueueItem,
typeQueue,
IQueueManager,
HandleAction,
HandleActions,
};
export { VirtualDrive, QueueItem, typeQueue, IQueueManager, HandleAction, HandleActions, QueueManager };
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
"@types/jest": "^29.5.12",
"@types/lodash.chunk": "^4.2.9",
"@types/node": "^20.5.0",
"@types/yargs": "^17.0.32",
"jest": "^29.7.0",
Expand All @@ -49,6 +50,7 @@
},
"dependencies": {
"chokidar": "^3.6.0",
"lodash.chunk": "^4.2.0",
"pino": "^9.6.0",
"pino-pretty": "^13.0.0",
"tsconfig-paths": "^4.2.0",
Expand Down
9 changes: 0 additions & 9 deletions src/index.ts

This file was deleted.

Loading