mirror of
https://github.com/Swatinem/rust-cache
synced 2025-06-28 02:58:47 +00:00
fix: cache key stability (#142)
Ensure consistency of main and post configuration by storing and restoring it from state, which in turn ensures cache key stability. Also: * Fixed some typos. * Use core.error for logging errors. * Fix inverted condition on cache-all-crates. Reverts: #138 Fixes #140
This commit is contained in:
parent
060bda31e0
commit
ad97570a01
9 changed files with 260 additions and 175 deletions
|
@ -3,7 +3,7 @@ import * as io from "@actions/io";
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
import { CARGO_HOME, STATE_BINS } from "./config";
|
||||
import { CARGO_HOME } from "./config";
|
||||
import { Packages } from "./workspace";
|
||||
|
||||
export async function cleanTargetDir(targetDir: string, packages: Packages, checkTimestamp = false) {
|
||||
|
@ -69,9 +69,14 @@ export async function getCargoBins(): Promise<Set<string>> {
|
|||
return bins;
|
||||
}
|
||||
|
||||
export async function cleanBin() {
|
||||
/**
|
||||
* Clean the cargo bin directory, removing the binaries that existed
|
||||
* when the action started, as they were not created by the build.
|
||||
*
|
||||
* @param oldBins The binaries that existed when the action started.
|
||||
*/
|
||||
export async function cleanBin(oldBins: Array<string>) {
|
||||
const bins = await getCargoBins();
|
||||
const oldBins = JSON.parse(core.getState(STATE_BINS));
|
||||
|
||||
for (const bin of oldBins) {
|
||||
bins.delete(bin);
|
||||
|
@ -186,10 +191,10 @@ const ONE_WEEK = 7 * 24 * 3600 * 1000;
|
|||
|
||||
/**
|
||||
* Removes all files or directories in `dirName` matching some criteria.
|
||||
*
|
||||
*
|
||||
* When the `checkTimestamp` flag is set, this will also remove anything older
|
||||
* than one week.
|
||||
*
|
||||
*
|
||||
* Otherwise, it will remove everything that does not match any string in the
|
||||
* `keepPrefix` set.
|
||||
* The matching strips and trailing `-$hash` suffix.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue