39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { workerData, parentPort } from 'worker_threads';
|
|
import { BackupRetrievalWorker} from '../helpers/backup_retrieval'; // Assuming the class is in the same folder
|
|
|
|
// Destructure the data passed from the WorkerManager
|
|
const {
|
|
userConfigPath,
|
|
applicationInfoPath,
|
|
clientPort,
|
|
destinationPath
|
|
}: {
|
|
userConfigPath: string,
|
|
applicationInfoPath: string,
|
|
clientPort: number,
|
|
destinationPath: string
|
|
} = workerData;
|
|
|
|
// Initialize the BackupRetrievalWorker
|
|
const backupRetrievalWorker = new BackupRetrievalWorker(
|
|
userConfigPath,
|
|
applicationInfoPath,
|
|
clientPort,
|
|
destinationPath
|
|
);
|
|
|
|
// Start the backup retrieval process
|
|
backupRetrievalWorker.start()
|
|
.then(() => {
|
|
parentPort?.postMessage({
|
|
success: true,
|
|
message: 'Backup retrieval completed successfully.'
|
|
});
|
|
})
|
|
.catch((error: any) => {
|
|
parentPort?.postMessage({
|
|
success: false,
|
|
message: `Backup retrieval failed: ${error.message}`
|
|
});
|
|
});
|