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