2020-10-09 19:35:46 +02:00
|
|
|
import { ImportExportResult } from './types';
|
|
|
|
|
2021-01-22 19:41:11 +02:00
|
|
|
import InteropService_Importer_Base from './InteropService_Importer_Base';
|
|
|
|
import InteropService_Importer_Raw from './InteropService_Importer_Raw';
|
2020-11-05 18:58:23 +02:00
|
|
|
const { filename } = require('../../path-utils');
|
2021-01-27 19:42:58 +02:00
|
|
|
import shim from '../../shim';
|
|
|
|
|
2018-02-26 21:25:54 +02:00
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
2020-10-09 19:35:46 +02:00
|
|
|
export default class InteropService_Importer_Jex extends InteropService_Importer_Base {
|
2020-11-12 21:13:28 +02:00
|
|
|
async exec(result: ImportExportResult) {
|
2018-02-26 21:25:54 +02:00
|
|
|
const tempDir = await this.temporaryDirectory_(true);
|
|
|
|
|
|
|
|
try {
|
2021-01-27 19:42:58 +02:00
|
|
|
await shim.fsDriver().tarExtract({
|
2018-02-26 21:25:54 +02:00
|
|
|
strict: true,
|
|
|
|
portable: true,
|
|
|
|
file: this.sourcePath_,
|
|
|
|
cwd: tempDir,
|
|
|
|
});
|
|
|
|
} catch (error) {
|
2021-05-13 22:13:53 +02:00
|
|
|
error.message = `Could not decompress "${this.sourcePath_}". The file may be corrupted. Error was: ${error.message}`;
|
|
|
|
throw error;
|
2018-02-26 21:25:54 +02:00
|
|
|
}
|
|
|
|
|
2018-03-01 20:35:17 +02:00
|
|
|
if (!('defaultFolderTitle' in this.options_)) this.options_.defaultFolderTitle = filename(this.sourcePath_);
|
|
|
|
|
2018-02-26 21:25:54 +02:00
|
|
|
const importer = new InteropService_Importer_Raw();
|
|
|
|
await importer.init(tempDir, this.options_);
|
|
|
|
result = await importer.exec(result);
|
|
|
|
|
|
|
|
await fs.remove(tempDir);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|