This commit is contained in:
andrei-mihnea-cerbu
2025-02-25 21:08:16 +02:00
parent 26ae03dcea
commit a7d8b72205
2 changed files with 5 additions and 10 deletions
+3 -3
View File
@@ -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
+2 -7
View File
@@ -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