Commit 897b2c84 authored by mercury233's avatar mercury233

fix single quote in user dir name

parent 2165d969
......@@ -1008,18 +1008,21 @@ export class AppsService {
extract(file: string, dir: string): Observable<string> {
return Observable.create((observer: Observer<string>) => {
let tarPath = this.tarPath;
const tarArgs = ['-xvf', file, '-C', dir];
if(process.platform === 'darwin') {
tarArgs.unshift(`--use-compress-program=${this.systemBinPath('zstd')}`)
}
let windowsArgumentsQuoted: boolean = false;
if ((file.includes('\'') || dir.includes('\'')) && process.platform === 'win32') {
if ((file.includes('\'') || dir.includes('\'') || tarPath.includes('\'')) && process.platform === 'win32') {
windowsArgumentsQuoted = true;
tarArgs[1] = `"${file}"`;
tarArgs[3] = `"${dir}"`;
tarPath = `"${tarPath}"`;
}
Logger.info('Start to extract... Command Line: ' + this.tarPath, tarArgs.join(' '));
let tarProcess = child_process.spawn(this.tarPath, tarArgs, { windowsVerbatimArguments: windowsArgumentsQuoted });
Logger.info('Start to extract...');
Logger.info('Command Line: ' + tarPath, tarArgs.join(' '));
let tarProcess = child_process.spawn(tarPath, tarArgs, { shell: windowsArgumentsQuoted });
let rl = readline.createInterface({
input: this.getTarStream(tarProcess),
});
......@@ -1029,7 +1032,7 @@ export class AppsService {
});
tarProcess.on('error', (e) => {
console.log(e);
console.log(tarProcess.spawnargs);
Logger.info('spawnargs', tarProcess.spawnargs);
new Notification('MyCard', { body: '解压失败 ' + e.message });
observer.error(e);
});
......@@ -1039,7 +1042,7 @@ export class AppsService {
} else {
let e = new Error('tarProcess错误码:' + code);
console.log(e);
console.log(tarProcess.spawnargs);
Logger.info('spawnargs', tarProcess.spawnargs);
new Notification('MyCard', { body: '解压失败 ' + e.message });
observer.error(e);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment