2020-10-09 18:35:46 +01:00
|
|
|
/* eslint @typescript-eslint/no-unused-vars: 0, no-unused-vars: 0 */
|
|
|
|
|
|
|
|
import { ImportExportResult } from './types';
|
|
|
|
|
2021-01-22 17:41:11 +00:00
|
|
|
import Setting from '../../models/Setting';
|
2020-10-09 18:35:46 +01:00
|
|
|
|
|
|
|
export default class InteropService_Importer_Base {
|
2021-09-04 15:07:38 +01:00
|
|
|
|
2020-11-12 19:13:28 +00:00
|
|
|
private metadata_: any = null;
|
|
|
|
protected sourcePath_: string = '';
|
2020-11-12 19:29:22 +00:00
|
|
|
protected options_: any = {};
|
2020-10-09 18:35:46 +01:00
|
|
|
|
2021-09-04 15:07:38 +01:00
|
|
|
public setMetadata(md: any) {
|
2020-10-09 18:35:46 +01:00
|
|
|
this.metadata_ = md;
|
|
|
|
}
|
|
|
|
|
2021-09-04 15:07:38 +01:00
|
|
|
public metadata() {
|
2020-10-09 18:35:46 +01:00
|
|
|
return this.metadata_;
|
|
|
|
}
|
|
|
|
|
2021-09-04 15:07:38 +01:00
|
|
|
public async init(sourcePath: string, options: any) {
|
2020-10-09 18:35:46 +01:00
|
|
|
this.sourcePath_ = sourcePath;
|
|
|
|
this.options_ = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @ts-ignore
|
2021-09-04 15:07:38 +01:00
|
|
|
public async exec(result: ImportExportResult): Promise<ImportExportResult> {}
|
2020-10-09 18:35:46 +01:00
|
|
|
|
2021-09-04 15:07:38 +01:00
|
|
|
protected async temporaryDirectory_(createIt: boolean) {
|
2020-10-09 18:35:46 +01:00
|
|
|
const md5 = require('md5');
|
|
|
|
const tempDir = `${Setting.value('tempDir')}/${md5(Math.random() + Date.now())}`;
|
|
|
|
if (createIt) await require('fs-extra').mkdirp(tempDir);
|
|
|
|
return tempDir;
|
|
|
|
}
|
|
|
|
}
|