Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path.join #2046

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
22 changes: 15 additions & 7 deletions src/controller/miscController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

import { Request, Response } from 'express';

Check failure on line 17 in src/controller/miscController.ts

View workflow job for this annotation

GitHub Actions / lint

Run autofix to sort these imports!
import fs from 'fs';

import path from 'path';
import { logger } from '..';
import config from '../config';
import { backupSessions, restoreSessions } from '../util/manageSession';
Expand Down Expand Up @@ -160,15 +160,23 @@
delete clientsArray[req.params.session];
await req.client.logout();
}
const path = config.customUserDataDir + session;
const pathToken = __dirname + `../../../tokens/${session}.data.json`;
if (fs.existsSync(path)) {
await fs.promises.rm(path, {
const userDataPath = path.join(config.customUserDataDir, session);
const tokenFilePath = path.join(__dirname, '../../tokens', `${session}.data.json`);

Check failure on line 164 in src/controller/miscController.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `__dirname,·'../../tokens',·`${session}.data.json`` with `⏎······__dirname,⏎······'../../tokens',⏎······`${session}.data.json`⏎····`
if (fs.existsSync(userDataPath)) {
await fs.promises.rm(userDataPath, {
recursive: true,
maxRetries: 5,
force: true,
retryDelay: 1000,
});
}
if (fs.existsSync(pathToken)) {
await fs.promises.rm(pathToken);
if (fs.existsSync(tokenFilePath)) {
await fs.promises.rm(tokenFilePath, {
recursive: true,
maxRetries: 5,
force: true,
retryDelay: 1000,
});
}
return res.status(200).json({ success: true });
} catch (error: any) {
Expand Down
Loading