2020-10-09 19:35:46 +02:00
|
|
|
/* eslint @typescript-eslint/no-unused-vars: 0, no-unused-vars: 0 */
|
|
|
|
|
2024-01-10 00:03:34 +02:00
|
|
|
import { ImportExportResult, ImportOptions } from './types';
|
2020-10-09 19:35:46 +02:00
|
|
|
|
2021-01-22 19:41:11 +02:00
|
|
|
import Setting from '../../models/Setting';
|
2023-07-18 15:58:06 +02:00
|
|
|
import shim from '../../shim';
|
2024-01-10 00:03:34 +02:00
|
|
|
import { type ImportMetadata } from './Module';
|
2020-10-09 19:35:46 +02:00
|
|
|
|
|
|
|
export default class InteropService_Importer_Base {
|
2021-09-04 16:07:38 +02:00
|
|
|
|
2024-01-10 00:03:34 +02:00
|
|
|
private metadata_: ImportMetadata = null;
|
2023-06-30 10:07:03 +02:00
|
|
|
protected sourcePath_ = '';
|
2024-01-10 00:03:34 +02:00
|
|
|
protected options_: ImportOptions = {};
|
2020-10-09 19:35:46 +02:00
|
|
|
|
2021-09-04 16:07:38 +02:00
|
|
|
public setMetadata(md: any) {
|
2020-10-09 19:35:46 +02:00
|
|
|
this.metadata_ = md;
|
|
|
|
}
|
|
|
|
|
2021-09-04 16:07:38 +02:00
|
|
|
public metadata() {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.metadata_;
|
|
|
|
}
|
|
|
|
|
2021-09-04 16:07:38 +02:00
|
|
|
public async init(sourcePath: string, options: any) {
|
2020-10-09 19:35:46 +02:00
|
|
|
this.sourcePath_ = sourcePath;
|
|
|
|
this.options_ = options;
|
|
|
|
}
|
|
|
|
|
2023-06-30 11:22:47 +02:00
|
|
|
public async exec(_result: ImportExportResult): Promise<ImportExportResult> { return null; }
|
2020-10-09 19:35:46 +02:00
|
|
|
|
2021-09-04 16:07:38 +02:00
|
|
|
protected async temporaryDirectory_(createIt: boolean) {
|
2020-10-09 19:35:46 +02:00
|
|
|
const md5 = require('md5');
|
|
|
|
const tempDir = `${Setting.value('tempDir')}/${md5(Math.random() + Date.now())}`;
|
2023-07-18 15:58:06 +02:00
|
|
|
if (createIt) await shim.fsDriver().mkdir(tempDir);
|
2020-10-09 19:35:46 +02:00
|
|
|
return tempDir;
|
|
|
|
}
|
|
|
|
}
|