1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-27 10:32:58 +02:00
joplin/packages/lib/services/interop/InteropService_Importer_Jex.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

import { ImportExportResult } from './types';
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';
export default class InteropService_Importer_Jex extends InteropService_Importer_Base {
public async exec(result: ImportExportResult) {
const tempDir = await this.temporaryDirectory_(true);
try {
2021-01-27 19:42:58 +02:00
await shim.fsDriver().tarExtract({
strict: true,
portable: true,
file: this.sourcePath_,
cwd: tempDir,
});
} catch (error) {
error.message = `Could not decompress "${this.sourcePath_}". The file may be corrupted. Error was: ${error.message}`;
throw error;
}
if (!('defaultFolderTitle' in this.options_)) this.options_.defaultFolderTitle = filename(this.sourcePath_);
const importer = new InteropService_Importer_Raw();
await importer.init(tempDir, this.options_);
result = await importer.exec(result);
2023-07-18 15:58:06 +02:00
await shim.fsDriver().remove(tempDir);
return result;
}
}