updated backup manager to also clean II
This commit is contained in:
@@ -8,13 +8,13 @@ import { Database } from '../database/database'
|
|||||||
import { NetworkUserScheme } from '../database/schemes/network_scheme'
|
import { NetworkUserScheme } from '../database/schemes/network_scheme'
|
||||||
import { UserInfoScheme } from '../database/schemes/app_config_scheme'
|
import { UserInfoScheme } from '../database/schemes/app_config_scheme'
|
||||||
|
|
||||||
const backupDirectoryPath = path.join(__dirname, '..', 'backup')
|
const backupDirectoryPath = path.join(__dirname, '..', 'backups')
|
||||||
|
|
||||||
export class BackupManager {
|
export class BackupManager {
|
||||||
private fileEncryptor: FileEncryptor | null = null
|
private fileEncryptor: FileEncryptor | null = null
|
||||||
private readonly db: Database
|
private readonly db: Database
|
||||||
private readonly port: number
|
private readonly port: number
|
||||||
private serverIp: string = '';
|
private serverIp: string = ''
|
||||||
private isBusy: boolean = false
|
private isBusy: boolean = false
|
||||||
private intervalId: NodeJS.Timeout | null = null
|
private intervalId: NodeJS.Timeout | null = null
|
||||||
private stopRequested: boolean = false
|
private stopRequested: boolean = false
|
||||||
@@ -24,7 +24,7 @@ export class BackupManager {
|
|||||||
this.port = port
|
this.port = port
|
||||||
this.db.read().then((data) => {
|
this.db.read().then((data) => {
|
||||||
this.serverIp = data.network.serverIp
|
this.serverIp = data.network.serverIp
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async start(): Promise<void> {
|
async start(): Promise<void> {
|
||||||
@@ -59,7 +59,7 @@ export class BackupManager {
|
|||||||
backupDirectoryData.path,
|
backupDirectoryData.path,
|
||||||
)
|
)
|
||||||
|
|
||||||
await this.validateBackupDirectories(backupDirectoryPath);
|
await this.validateBackupDirectories(backupDirectoryPath)
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
this.log(`Error in initialize process: ${error.message}`, 'error')
|
this.log(`Error in initialize process: ${error.message}`, 'error')
|
||||||
} finally {
|
} finally {
|
||||||
@@ -120,9 +120,9 @@ export class BackupManager {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingDirectories = fs.readdirSync(backupDirectoryPath).filter((dir) =>
|
const existingDirectories = fs
|
||||||
fs.statSync(path.join(backupDirectoryPath, dir)).isDirectory()
|
.readdirSync(backupDirectoryPath)
|
||||||
)
|
.filter((dir) => fs.statSync(path.join(backupDirectoryPath, dir)).isDirectory())
|
||||||
|
|
||||||
for (const directory of existingDirectories) {
|
for (const directory of existingDirectories) {
|
||||||
if (!validUserDirectories.has(directory)) {
|
if (!validUserDirectories.has(directory)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user