Use path.resolve to convert archive input to absolute paths
parent
7596121912
commit
4dd7a41e77
|
|
@ -546,39 +546,42 @@ class Caching {
|
||||||
if (__1.Input.cloudRunnerTests) {
|
if (__1.Input.cloudRunnerTests) {
|
||||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`ls`);
|
yield cloud_runner_system_1.CloudRunnerSystem.Run(`ls`);
|
||||||
}
|
}
|
||||||
console_1.assert(fs_1.default.existsSync(`./../${path_1.default.basename(sourceFolder)}`));
|
console_1.assert(fs_1.default.existsSync(`${path_1.default.basename(sourceFolder)}`));
|
||||||
const output = fs_1.default.createWriteStream(`${cacheKey}.zip`);
|
yield new Promise((resolve) => {
|
||||||
const archive = archiver_1.default('zip', {
|
const output = fs_1.default.createWriteStream(`${cacheKey}.zip`);
|
||||||
zlib: { level: 9 }, // Sets the compression level.
|
const archive = archiver_1.default('zip', {
|
||||||
});
|
zlib: { level: 9 }, // Sets the compression level.
|
||||||
output.on('close', function () {
|
});
|
||||||
cloud_runner_logger_1.default.log(`${archive.pointer()} total bytes`);
|
output.on('close', function () {
|
||||||
cloud_runner_logger_1.default.log('archiver has been finalized and the output file descriptor has closed.');
|
cloud_runner_logger_1.default.log(`${archive.pointer()} total bytes`);
|
||||||
});
|
cloud_runner_logger_1.default.log('archiver has been finalized and the output file descriptor has closed.');
|
||||||
output.on('end', function () {
|
resolve();
|
||||||
cloud_runner_logger_1.default.log('Data has been drained');
|
});
|
||||||
});
|
output.on('end', function () {
|
||||||
archive.on('warning', function (error) {
|
cloud_runner_logger_1.default.log('Data has been drained');
|
||||||
if (error.code === 'ENOENT') {
|
});
|
||||||
// log warning
|
archive.on('warning', function (error) {
|
||||||
cloud_runner_logger_1.default.logWarning(error);
|
if (error.code === 'ENOENT') {
|
||||||
}
|
// log warning
|
||||||
else {
|
cloud_runner_logger_1.default.logWarning(error);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
archive.on('error', function (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
});
|
||||||
|
archive.pipe(output);
|
||||||
|
archive.directory(path_1.default.resolve(`./../${path_1.default.basename(sourceFolder)}`), false);
|
||||||
|
archive.finalize();
|
||||||
});
|
});
|
||||||
archive.on('error', function (error) {
|
console_1.assert(fs_1.default.existsSync(`${cacheKey}.zip`), 'cache zip exists');
|
||||||
throw error;
|
console_1.assert(fs_1.default.existsSync(`${cacheFolder}`), 'cache folder');
|
||||||
});
|
console_1.assert(fs_1.default.existsSync(path_1.default.resolve(`./../${path_1.default.basename(sourceFolder)}`)), 'source folder exists');
|
||||||
archive.pipe(output);
|
|
||||||
archive.directory(`./../${path_1.default.basename(sourceFolder)}/`, false);
|
|
||||||
archive.finalize();
|
|
||||||
console_1.assert(fs_1.default.existsSync(`${cacheKey}.zip`));
|
|
||||||
console_1.assert(fs_1.default.existsSync(`${cacheFolder}`));
|
|
||||||
console_1.assert(fs_1.default.existsSync(`./../${path_1.default.basename(sourceFolder)}`));
|
|
||||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
|
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
|
remote_client_logger_1.RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
|
||||||
console_1.assert(fs_1.default.existsSync(`${path_1.default.join(cacheFolder, cacheKey)}.zip`));
|
console_1.assert(fs_1.default.existsSync(`${path_1.default.join(cacheFolder, cacheKey)}.zip`), 'cache zip exists inside cache folder');
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
process.chdir(`${startPath}`);
|
process.chdir(`${startPath}`);
|
||||||
|
|
@ -612,7 +615,7 @@ class Caching {
|
||||||
console_1.assert(`${fs_1.default.existsSync(destinationFolder)}`);
|
console_1.assert(`${fs_1.default.existsSync(destinationFolder)}`);
|
||||||
yield extract_zip_1.default(cacheSelection, { dir: `${path_1.default.basename(destinationFolder)}/` });
|
yield extract_zip_1.default(cacheSelection, { dir: `${path_1.default.basename(destinationFolder)}/` });
|
||||||
process.chdir(path_1.default.basename(destinationFolder));
|
process.chdir(path_1.default.basename(destinationFolder));
|
||||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mv "${path_1.default.basename(destinationFolder)}/*" "${destinationFolder}/.."`);
|
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mv "${path_1.default.basename(destinationFolder)}/*" "${path_1.default.resolve(`${destinationFolder}/..`)}"`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`);
|
remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -30,38 +30,41 @@ export class Caching {
|
||||||
if (Input.cloudRunnerTests) {
|
if (Input.cloudRunnerTests) {
|
||||||
await CloudRunnerSystem.Run(`ls`);
|
await CloudRunnerSystem.Run(`ls`);
|
||||||
}
|
}
|
||||||
assert(fs.existsSync(`./../${path.basename(sourceFolder)}`));
|
assert(fs.existsSync(`${path.basename(sourceFolder)}`));
|
||||||
const output = fs.createWriteStream(`${cacheKey}.zip`);
|
await new Promise<void>((resolve) => {
|
||||||
const archive = archiver('zip', {
|
const output = fs.createWriteStream(`${cacheKey}.zip`);
|
||||||
zlib: { level: 9 }, // Sets the compression level.
|
const archive = archiver('zip', {
|
||||||
});
|
zlib: { level: 9 }, // Sets the compression level.
|
||||||
output.on('close', function () {
|
});
|
||||||
CloudRunnerLogger.log(`${archive.pointer()} total bytes`);
|
output.on('close', function () {
|
||||||
CloudRunnerLogger.log('archiver has been finalized and the output file descriptor has closed.');
|
CloudRunnerLogger.log(`${archive.pointer()} total bytes`);
|
||||||
});
|
CloudRunnerLogger.log('archiver has been finalized and the output file descriptor has closed.');
|
||||||
output.on('end', function () {
|
resolve();
|
||||||
CloudRunnerLogger.log('Data has been drained');
|
});
|
||||||
});
|
output.on('end', function () {
|
||||||
archive.on('warning', function (error) {
|
CloudRunnerLogger.log('Data has been drained');
|
||||||
if (error.code === 'ENOENT') {
|
});
|
||||||
// log warning
|
archive.on('warning', function (error) {
|
||||||
CloudRunnerLogger.logWarning(error);
|
if (error.code === 'ENOENT') {
|
||||||
} else {
|
// log warning
|
||||||
|
CloudRunnerLogger.logWarning(error);
|
||||||
|
} else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
archive.on('error', function (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
});
|
||||||
|
archive.pipe(output);
|
||||||
|
archive.directory(path.resolve(`./../${path.basename(sourceFolder)}`), false);
|
||||||
|
archive.finalize();
|
||||||
});
|
});
|
||||||
archive.on('error', function (error) {
|
assert(fs.existsSync(`${cacheKey}.zip`), 'cache zip exists');
|
||||||
throw error;
|
assert(fs.existsSync(`${cacheFolder}`), 'cache folder');
|
||||||
});
|
assert(fs.existsSync(path.resolve(`./../${path.basename(sourceFolder)}`)), 'source folder exists');
|
||||||
archive.pipe(output);
|
|
||||||
archive.directory(`./../${path.basename(sourceFolder)}/`, false);
|
|
||||||
archive.finalize();
|
|
||||||
assert(fs.existsSync(`${cacheKey}.zip`));
|
|
||||||
assert(fs.existsSync(`${cacheFolder}`));
|
|
||||||
assert(fs.existsSync(`./../${path.basename(sourceFolder)}`));
|
|
||||||
await CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
|
await CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
|
||||||
RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
|
RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
|
||||||
assert(fs.existsSync(`${path.join(cacheFolder, cacheKey)}.zip`));
|
assert(fs.existsSync(`${path.join(cacheFolder, cacheKey)}.zip`), 'cache zip exists inside cache folder');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
process.chdir(`${startPath}`);
|
process.chdir(`${startPath}`);
|
||||||
throw error;
|
throw error;
|
||||||
|
|
@ -97,7 +100,9 @@ export class Caching {
|
||||||
assert(`${fs.existsSync(destinationFolder)}`);
|
assert(`${fs.existsSync(destinationFolder)}`);
|
||||||
await extract(cacheSelection, { dir: `${path.basename(destinationFolder)}/` });
|
await extract(cacheSelection, { dir: `${path.basename(destinationFolder)}/` });
|
||||||
process.chdir(path.basename(destinationFolder));
|
process.chdir(path.basename(destinationFolder));
|
||||||
await CloudRunnerSystem.Run(`mv "${path.basename(destinationFolder)}/*" "${destinationFolder}/.."`);
|
await CloudRunnerSystem.Run(
|
||||||
|
`mv "${path.basename(destinationFolder)}/*" "${path.resolve(`${destinationFolder}/..`)}"`,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`);
|
RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`);
|
||||||
if (cacheSelection !== ``) {
|
if (cacheSelection !== ``) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue