35 lines
888 B
JavaScript
35 lines
888 B
JavaScript
|
const removeDir = require('./remove_dir');
|
||
|
const copyFolder = require('./copyFolder');
|
||
|
const path = require('path');
|
||
|
const fs = require('fs');
|
||
|
|
||
|
|
||
|
async function restore(client) {
|
||
|
|
||
|
await client.destroy()
|
||
|
|
||
|
const sessionBackupPath = path.join(process.cwd(), `session_backup`, `session-omnihit_sesssion`)
|
||
|
|
||
|
const sessionPath = path.join(process.cwd(), '.wwebjs_auth', 'session-omnihit_sesssion')
|
||
|
|
||
|
if (fs.existsSync(path.join(process.cwd(), `session_backup`, `session-omnihit_sesssion`))) {
|
||
|
|
||
|
await removeDir(sessionPath)
|
||
|
|
||
|
// copy the good session for backup dir
|
||
|
copyFolder(sessionBackupPath, sessionPath)
|
||
|
|
||
|
}
|
||
|
else {
|
||
|
console.log('Directory not found to copy: ', sessionPath)
|
||
|
}
|
||
|
|
||
|
|
||
|
setTimeout(() => {
|
||
|
console.log('process.exit: kkkkkkkkkkkkkkkkkkkkk')
|
||
|
process.exit()
|
||
|
}, 5000)
|
||
|
|
||
|
}
|
||
|
|
||
|
module.exports = restore;
|