Fix review points

This commit is contained in:
Ivan Zosimov 2022-04-20 17:36:08 +02:00
parent 832658fa34
commit ede5159e42
2 changed files with 16 additions and 18 deletions

View file

@ -49203,16 +49203,13 @@ const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () {
const primaryKey = core.getState(constants_1.State.CachePrimaryKey); const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo);
let pathsCounter = cachePaths.length; const nonExistingPaths = cachePaths.filter(cachePath => !fs_1.default.existsSync(cachePath));
for (let path of cachePaths) { if (nonExistingPaths.length === cachePaths.length) {
if (!fs_1.default.existsSync(path)) {
logWarning(`Cache folder path is retrieved but doesn't exist on disk: ${path}`);
pathsCounter--;
}
}
if (!pathsCounter) {
throw new Error(`No cache folders exist on disk`); throw new Error(`No cache folders exist on disk`);
} }
if (nonExistingPaths.length) {
logWarning(`Cache folder path is retrieved but doesn't exist on disk: ${nonExistingPaths.join(', ')}`);
}
if (primaryKey === state) { if (primaryKey === state) {
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
return; return;

View file

@ -35,19 +35,20 @@ const cachePackages = async () => {
const cachePaths = await getCacheDirectoryPath(packageManagerInfo); const cachePaths = await getCacheDirectoryPath(packageManagerInfo);
let pathsCounter = cachePaths.length; const nonExistingPaths = cachePaths.filter(
cachePath => !fs.existsSync(cachePath)
);
for (let path of cachePaths) { if (nonExistingPaths.length === cachePaths.length) {
if (!fs.existsSync(path)) { throw new Error(`No cache folders exist on disk`);
logWarning(
`Cache folder path is retrieved but doesn't exist on disk: ${path}`
);
pathsCounter--;
}
} }
if (!pathsCounter) { if (nonExistingPaths.length) {
throw new Error(`No cache folders exist on disk`); logWarning(
`Cache folder path is retrieved but doesn't exist on disk: ${nonExistingPaths.join(
', '
)}`
);
} }
if (primaryKey === state) { if (primaryKey === state) {