Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit c60b1fd

Browse files
James Walliselsony
authored andcommitted
use tempdir
Signed-off-by: James Wallis <james.wallis1@ibm.com>
1 parent c845af8 commit c60b1fd

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/pfe/portal/modules/utils/installExtensions.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ const defaultExtensionsDir = '/extensions';
2222
const extensionsPattern = /^(\S+)-(\d+\.\d+\.\d+|latest)\.zip$/; // e.g. extension-name-0.0.1.zip
2323
const versionPattern = /^\d+[.]\d+[.]\d+$/; // e.g. 0.0.1
2424
const SUFFIX_OLD = '__old';
25-
const odoExtensionName = "codewind-odo-extension";
26-
const odoDevfileExtensionName = "codewind-odo-extension-devfile";
25+
const odoExtensionNamePrefix = "codewind-odo";
2726

2827
/**
2928
* Install (unzip) built-in extensions that are stored in /extensions to the
@@ -59,13 +58,13 @@ async function installBuiltInExtension(file, targetDir, extensionsDir) {
5958
const version = match[2];
6059
log.trace(`extensionPattern - name: ${name}, version ${version}`);
6160

62-
if (([odoExtensionName, odoDevfileExtensionName].includes(name)) && (process.env.ON_OPENSHIFT != 'true')) {
61+
if (name.startsWith(odoExtensionNamePrefix) && (process.env.ON_OPENSHIFT != 'true')) {
6362
return;
6463
}
6564

6665
const source = path.join(extensionsDir, file.name);
6766
const target = path.join(targetDir, name);
68-
const directoryToUnzipTo = `temp_${target}`;
67+
const directoryToUnzipTo = `${target}_temp`;
6968

7069
try {
7170
if (await prepForUnzip(target, version)) {
@@ -76,7 +75,8 @@ async function installBuiltInExtension(file, targetDir, extensionsDir) {
7675

7776
// Move unzipped files up a directory and to their final name
7877
const [parentDirFromZip] = await fs.readdir(directoryToUnzipTo);
79-
await fs.rename(path.join(directoryToUnzipTo, parentDirFromZip), target);
78+
const tempDir = path.join(directoryToUnzipTo, parentDirFromZip);
79+
await fs.rename(tempDir, target);
8080
}
8181
}
8282
catch (err) {

0 commit comments

Comments
 (0)