mirror of
https://github.com/actions/setup-python.git
synced 2025-06-28 05:33:47 +00:00
logic update
This commit is contained in:
parent
f36c8371b9
commit
0511a23861
3 changed files with 73 additions and 59 deletions
38
dist/setup/index.js
vendored
38
dist/setup/index.js
vendored
|
@ -96931,26 +96931,28 @@ function cacheDependencies(cache, pythonVersion) {
|
|||
const sourcePath = path.resolve(actionPath, cacheDependencyPath);
|
||||
const relativePath = path.relative(actionPath, sourcePath);
|
||||
const targetPath = path.resolve(workspace, relativePath);
|
||||
if (!fs_1.default.existsSync(sourcePath)) {
|
||||
core.warning(`The resolved cache-dependency-path does not exist: ${sourcePath}`);
|
||||
}
|
||||
else {
|
||||
if (sourcePath !== targetPath) {
|
||||
try {
|
||||
const targetDir = path.dirname(targetPath);
|
||||
if (!fs_1.default.existsSync(targetDir)) {
|
||||
fs_1.default.mkdirSync(targetDir, { recursive: true });
|
||||
}
|
||||
fs_1.default.copyFileSync(sourcePath, targetPath);
|
||||
core.info(`Copied ${sourcePath} to ${targetPath}`);
|
||||
}
|
||||
catch (error) {
|
||||
core.warning(`Failed to copy file from ${sourcePath} to ${targetPath}: ${error}`);
|
||||
}
|
||||
try {
|
||||
const sourceExists = yield fs_1.default.promises
|
||||
.access(sourcePath, fs_1.default.constants.F_OK)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
if (!sourceExists) {
|
||||
core.warning(`The resolved cache-dependency-path does not exist: ${sourcePath}`);
|
||||
}
|
||||
else if (sourcePath !== targetPath) {
|
||||
const targetDir = path.dirname(targetPath);
|
||||
// Create target directory if it doesn't exist
|
||||
yield fs_1.default.promises.mkdir(targetDir, { recursive: true });
|
||||
// Copy file asynchronously
|
||||
yield fs_1.default.promises.copyFile(sourcePath, targetPath);
|
||||
core.info(`Copied ${sourcePath} to ${targetPath}`);
|
||||
}
|
||||
resolvedDependencyPath = path.relative(workspace, targetPath);
|
||||
core.info(`Resolved cache-dependency-path: ${resolvedDependencyPath}`);
|
||||
}
|
||||
catch (error) {
|
||||
core.warning(`Failed to copy file from ${sourcePath} to ${targetPath}: ${error}`);
|
||||
}
|
||||
resolvedDependencyPath = path.relative(workspace, targetPath);
|
||||
core.info(`Resolved cache-dependency-path: ${resolvedDependencyPath}`);
|
||||
}
|
||||
const cacheDistributor = (0, cache_factory_1.getCacheDistributor)(cache, pythonVersion, cacheDependencyPath);
|
||||
yield cacheDistributor.restoreCache();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue