mirror of
https://github.com/Swatinem/rust-cache
synced 2025-04-07 05:44:07 +00:00
work around macos cache corruption
This commit is contained in:
parent
06ff70612d
commit
e0c07d2a65
15
src/save.ts
15
src/save.ts
|
@ -1,5 +1,6 @@
|
||||||
import * as cache from "@actions/cache";
|
import * as cache from "@actions/cache";
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
import * as exec from "@actions/exec";
|
||||||
import * as io from "@actions/io";
|
import * as io from "@actions/io";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
@ -7,7 +8,7 @@ import { getCaches, getCmdOutput, getRegistryName, isValidEvent, paths } from ".
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
if (!isValidEvent()) {
|
if (!isValidEvent()) {
|
||||||
//return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -15,7 +16,11 @@ async function run() {
|
||||||
const registryName = await getRegistryName();
|
const registryName = await getRegistryName();
|
||||||
const packages = await getPackages();
|
const packages = await getPackages();
|
||||||
|
|
||||||
|
// TODO: remove this once https://github.com/actions/toolkit/pull/553 lands
|
||||||
|
await macOsWorkaround();
|
||||||
|
|
||||||
await pruneTarget(packages);
|
await pruneTarget(packages);
|
||||||
|
|
||||||
if (registryName) {
|
if (registryName) {
|
||||||
// save the index based on its revision
|
// save the index based on its revision
|
||||||
const indexRef = await getIndexRef(registryName);
|
const indexRef = await getIndexRef(registryName);
|
||||||
|
@ -131,3 +136,11 @@ async function rmExcept(dirName: string, keepPrefix: Set<string>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function macOsWorkaround() {
|
||||||
|
try {
|
||||||
|
// Workaround for https://github.com/actions/cache/issues/403
|
||||||
|
// Also see https://github.com/rust-lang/cargo/issues/8603
|
||||||
|
await exec.exec("sudo", ["/usr/sbin/purge"]);
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue