mirror of
https://github.com/actions/setup-python.git
synced 2025-07-18 10:18:21 +02:00
Code improvemnt: Rm CacheDistributor.cacheDependencyPath field and pass back from computeKeys instead, simplifying CacheDistributor.restoreCache error check. Rm now uneeded constant.ts file.
This commit is contained in:
parent
0024ce0d14
commit
d99639b3c5
5 changed files with 16 additions and 18 deletions
|
@ -8,10 +8,9 @@ import os from 'os';
|
|||
|
||||
import CacheDistributor from './cache-distributor';
|
||||
import {getLinuxInfo, IS_LINUX, IS_WINDOWS} from '../utils';
|
||||
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
|
||||
|
||||
class PipCache extends CacheDistributor {
|
||||
private cacheDependencyBackupPath: string = CACHE_DEPENDENCY_BACKUP_PATH;
|
||||
private cacheDependencyBackupPath = '**/pyproject.toml';
|
||||
protected readonly packageManager = 'pip';
|
||||
|
||||
constructor(
|
||||
|
@ -60,9 +59,12 @@ class PipCache extends CacheDistributor {
|
|||
}
|
||||
|
||||
protected async computeKeys() {
|
||||
const hash =
|
||||
(await glob.hashFiles(this.cacheDependencyPath)) ||
|
||||
(await glob.hashFiles(this.cacheDependencyBackupPath));
|
||||
let cacheDependencyPath = this.cacheDependencyPath;
|
||||
let hash = await glob.hashFiles(this.cacheDependencyPath);
|
||||
if(!hash) {
|
||||
hash = await glob.hashFiles(this.cacheDependencyBackupPath);
|
||||
cacheDependencyPath = this.cacheDependencyBackupPath;
|
||||
}
|
||||
let primaryKey = '';
|
||||
let restoreKey = '';
|
||||
|
||||
|
@ -77,7 +79,8 @@ class PipCache extends CacheDistributor {
|
|||
|
||||
return {
|
||||
primaryKey,
|
||||
restoreKey: [restoreKey]
|
||||
restoreKey: [restoreKey],
|
||||
cacheDependencyPath,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue