🔧 Some tweaks to the file watcher
This commit is contained in:
@@ -20,7 +20,6 @@ RUN apk add --update \
|
|||||||
xvfb \
|
xvfb \
|
||||||
xz
|
xz
|
||||||
|
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
COPY moleculer.config.ts ./
|
COPY moleculer.config.ts ./
|
||||||
COPY tsconfig.json ./
|
COPY tsconfig.json ./
|
||||||
|
|||||||
@@ -39,7 +39,6 @@
|
|||||||
"@elastic/elasticsearch": "^7.16.0",
|
"@elastic/elasticsearch": "^7.16.0",
|
||||||
"@jorgeferrero/stream-to-buffer": "^2.0.6",
|
"@jorgeferrero/stream-to-buffer": "^2.0.6",
|
||||||
"@root/walk": "^1.1.0",
|
"@root/walk": "^1.1.0",
|
||||||
"@types/axios": "^0.14.0",
|
|
||||||
"@types/jest": "^25.1.4",
|
"@types/jest": "^25.1.4",
|
||||||
"@types/mkdirp": "^1.0.0",
|
"@types/mkdirp": "^1.0.0",
|
||||||
"@types/node": "^13.9.8",
|
"@types/node": "^13.9.8",
|
||||||
@@ -61,9 +60,9 @@
|
|||||||
"mkdirp": "^0.5.5",
|
"mkdirp": "^0.5.5",
|
||||||
"moleculer": "^0.14.19",
|
"moleculer": "^0.14.19",
|
||||||
"moleculer-bull": "github:rishighan/moleculer-bull",
|
"moleculer-bull": "github:rishighan/moleculer-bull",
|
||||||
"moleculer-db": "^0.8.13",
|
"moleculer-db": "^0.8.17",
|
||||||
"moleculer-db-adapter-mongo": "^0.4.7",
|
"moleculer-db-adapter-mongo": "^0.4.7",
|
||||||
"moleculer-db-adapter-mongoose": "^0.8.9",
|
"moleculer-db-adapter-mongoose": "^0.8.12",
|
||||||
"moleculer-web": "^0.10.4",
|
"moleculer-web": "^0.10.4",
|
||||||
"mongoosastic-ts": "^5.0.7",
|
"mongoosastic-ts": "^5.0.7",
|
||||||
"mongoose": "^5.12.7",
|
"mongoose": "^5.12.7",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import fs from "fs";
|
|||||||
import { IExtractionOptions, IFolderData } from "threetwo-ui-typings";
|
import { IExtractionOptions, IFolderData } from "threetwo-ui-typings";
|
||||||
import { SocketIOMixin } from "../mixins/socket.io.mixin";
|
import { SocketIOMixin } from "../mixins/socket.io.mixin";
|
||||||
export const io = SocketIOMixin();
|
export const io = SocketIOMixin();
|
||||||
|
|
||||||
export default class ApiService extends Service {
|
export default class ApiService extends Service {
|
||||||
public constructor(broker: ServiceBroker) {
|
public constructor(broker: ServiceBroker) {
|
||||||
super(broker);
|
super(broker);
|
||||||
@@ -56,7 +57,9 @@ export default class ApiService extends Service {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/userdata",
|
path: "/userdata",
|
||||||
use: [ApiGateway.serveStatic(path.resolve("/userdata"))],
|
use: [
|
||||||
|
ApiGateway.serveStatic(path.resolve("/userdata")),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/comics",
|
path: "/comics",
|
||||||
@@ -97,7 +100,7 @@ export default class ApiService extends Service {
|
|||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case "LS_IMPORT":
|
case "LS_IMPORT":
|
||||||
// 1. Send task to queue
|
// 1. Send task to queue
|
||||||
console.log(`Recieved ${action.type} event.`)
|
console.log(`Recieved ${action.type} event.`);
|
||||||
await this.broker.call(
|
await this.broker.call(
|
||||||
"library.newImport",
|
"library.newImport",
|
||||||
action.data,
|
action.data,
|
||||||
@@ -105,8 +108,11 @@ export default class ApiService extends Service {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "LS_TOGGLE_IMPORT_QUEUE":
|
case "LS_TOGGLE_IMPORT_QUEUE":
|
||||||
console.log("lol")
|
await this.broker.call(
|
||||||
await this.broker.call("importqueue.toggleImportQueue", action.data, {});
|
"importqueue.toggleImportQueue",
|
||||||
|
action.data,
|
||||||
|
{}
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -148,12 +154,15 @@ export default class ApiService extends Service {
|
|||||||
await broker.call("library.walkFolders", {
|
await broker.call("library.walkFolders", {
|
||||||
basePathToWalk: path,
|
basePathToWalk: path,
|
||||||
});
|
});
|
||||||
await this.broker.call("importqueue.processImport", {
|
await this.broker.call(
|
||||||
|
"importqueue.processImport",
|
||||||
|
{
|
||||||
fileObject: {
|
fileObject: {
|
||||||
filePath: walkedFolder[0].filePath,
|
filePath: walkedFolder[0].filePath,
|
||||||
fileSize: walkedFolder[0].fileSize,
|
fileSize: walkedFolder[0].fileSize,
|
||||||
},
|
},
|
||||||
});
|
}
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(
|
setTimeout(
|
||||||
checkFileCopyComplete,
|
checkFileCopyComplete,
|
||||||
@@ -169,7 +178,7 @@ export default class ApiService extends Service {
|
|||||||
console.log("Watcher detected new files.");
|
console.log("Watcher detected new files.");
|
||||||
console.log(
|
console.log(
|
||||||
`File ${path} has been added with stats: ${JSON.stringify(
|
`File ${path} has been added with stats: ${JSON.stringify(
|
||||||
stats
|
stats, null, 2
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -200,7 +209,7 @@ export default class ApiService extends Service {
|
|||||||
})
|
})
|
||||||
.on("change", (path, stats) =>
|
.on("change", (path, stats) =>
|
||||||
console.log(
|
console.log(
|
||||||
`File ${path} has been changed. Stats: ${stats}`
|
`File ${path} has been changed. Stats: ${JSON.stringify(stats, null, 2)}`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.on("unlink", (path) =>
|
.on("unlink", (path) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user