done
This commit is contained in:
@@ -9,7 +9,7 @@ import { UserInfoScheme } from '../database/schemes/app_config_scheme'
|
|||||||
|
|
||||||
export class BackupRetrievalWorker {
|
export class BackupRetrievalWorker {
|
||||||
private db: Database
|
private db: Database
|
||||||
private readonly clientPort: number
|
private readonly port: number
|
||||||
private readonly destinationPath: string
|
private readonly destinationPath: string
|
||||||
private encryptionKey: Buffer | null = null
|
private encryptionKey: Buffer | null = null
|
||||||
private iv: Buffer | null = null
|
private iv: Buffer | null = null
|
||||||
@@ -19,7 +19,7 @@ export class BackupRetrievalWorker {
|
|||||||
|
|
||||||
constructor(pathToDatabaseFile: string, clientPort: number, destinationPath: string) {
|
constructor(pathToDatabaseFile: string, clientPort: number, destinationPath: string) {
|
||||||
this.db = new Database(pathToDatabaseFile)
|
this.db = new Database(pathToDatabaseFile)
|
||||||
this.clientPort = clientPort
|
this.port = clientPort
|
||||||
this.destinationPath = destinationPath
|
this.destinationPath = destinationPath
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ export class BackupRetrievalWorker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async processBackupForIp(ip: string, userInfo: UserInfoScheme): Promise<boolean> {
|
private async processBackupForIp(ip: string, userInfo: UserInfoScheme): Promise<boolean> {
|
||||||
this.tcpCommunicator = new TcpCommunicator(ip, this.clientPort)
|
this.tcpCommunicator = new TcpCommunicator(ip, this.port)
|
||||||
if (!(await this.tcpCommunicator.connect())) {
|
if (!(await this.tcpCommunicator.connect())) {
|
||||||
this.log(`Failed to connect to ${ip}`, 'error')
|
this.log(`Failed to connect to ${ip}`, 'error')
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -4,12 +4,7 @@ import { TcpCommunicator } from './tcp_communicator'
|
|||||||
import { operationCodes } from '../network/operation_codes'
|
import { operationCodes } from '../network/operation_codes'
|
||||||
import { ParsedMessage } from '../network/message_handler'
|
import { ParsedMessage } from '../network/message_handler'
|
||||||
import { Database } from '../database/database'
|
import { Database } from '../database/database'
|
||||||
|
import {FileItemTask} from "../database/schemes/local_resources_scheme";
|
||||||
interface FileSendTask {
|
|
||||||
ip: string
|
|
||||||
path: string
|
|
||||||
userName: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export class FileSharer {
|
export class FileSharer {
|
||||||
private readonly db: Database
|
private readonly db: Database
|
||||||
@@ -65,7 +60,7 @@ export class FileSharer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Method to send the file to a specific IP using TcpCommunicator
|
// Method to send the file to a specific IP using TcpCommunicator
|
||||||
private async sendFile(task: FileSendTask): Promise<boolean> {
|
private async sendFile(task: FileItemTask): Promise<boolean> {
|
||||||
const { ip, path: filePath, userName } = task
|
const { ip, path: filePath, userName } = task
|
||||||
|
|
||||||
// Ensure the file exists before attempting to send
|
// Ensure the file exists before attempting to send
|
||||||
|
|||||||
Reference in New Issue
Block a user