Upload latest files to correct location (#3693)

This commit is contained in:
Peter Hedenskog 2022-07-11 22:44:57 +02:00 committed by GitHub
parent fa85a83a2a
commit deb1c9407e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -53,14 +53,14 @@ async function upload(dir, scpOptions, prefix) {
}
}
async function uploadFiles(files, scpOptions) {
async function uploadFiles(files, scpOptions, prefix) {
let client;
try {
client = await getClient(scpOptions);
for (let file of files) {
await client.uploadFile(
file,
path.join(scpOptions.destinationPath, path.basename(file))
path.join(scpOptions.destinationPath, prefix, path.basename(file))
);
}
} catch (e) {
@ -73,13 +73,13 @@ async function uploadFiles(files, scpOptions) {
}
}
async function uploadLatestFiles(dir, scpOptions) {
async function uploadLatestFiles(dir, scpOptions, prefix) {
function ignoreDirs(file, stats) {
return stats.isDirectory();
}
const files = await readdir(dir, [ignoreDirs]);
return uploadFiles(files, scpOptions);
return uploadFiles(files, scpOptions, prefix);
}
module.exports = {
@ -111,7 +111,9 @@ module.exports = {
);
if (this.options.copyLatestFilesToBase) {
const rootPath = path.resolve(baseDir, '..');
await uploadLatestFiles(rootPath, this.scpOptions);
const prefix = this.storageManager.getStoragePrefix();
const firstPart = prefix.split('/')[0];
await uploadLatestFiles(rootPath, this.scpOptions, firstPart);
}
log.info('Finished upload using scp');
if (this.scpOptions.removeLocalResult) {