Skip to content

Commit

Permalink
fix: controle de erro ao apagar a pasta da sessão do whatsapp
Browse files Browse the repository at this point in the history
  • Loading branch information
ldurans committed Nov 10, 2022
1 parent 052c806 commit b794fb8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/src/libs/wbot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Client, LocalAuth, DefaultOptions } from "whatsapp-web.js";
import path from "path";
import { rmdir } from "fs/promises";
import { rm } from "fs/promises";
import { getIO } from "./socket";
import Whatsapp from "../models/Whatsapp";
import { logger } from "../utils/logger";
Expand All @@ -18,8 +18,12 @@ const checking: any = {};
export const apagarPastaSessao = async (id: number | string): Promise<void> => {
const pathRoot = path.resolve(__dirname, "..", "..", ".wwebjs_auth");
const pathSession = `${pathRoot}/session-wbot_${id}`;
const rm = await rmdir(pathSession, { recursive: true });
console.log(`apagarPastaSessao:: ${pathSession}`, rm);
try {
await rm(pathSession, { recursive: true, force: true });
} catch (error) {
logger.info(`apagarPastaSessao:: ${pathSession}`);
logger.error(error);
}
};

const checkMessages = async (wbot: Session, tenantId: number | string) => {
Expand Down

0 comments on commit b794fb8

Please sign in to comment.