mirror of
https://github.com/Swatinem/rust-cache.git
synced 2024-11-26 17:56:08 +08:00
Skip registry cleaning if no registry was found (#65)
This fixes #64. When Cargo is run in sparse-registry mode, it doesn't create ~/.cargo/registry/index/github.com-1ecc6299db9ec823/ directory.
This commit is contained in:
parent
2055a01dcd
commit
5040f39404
15
src/save.ts
15
src/save.ts
@ -36,10 +36,12 @@ async function run() {
|
|||||||
const registryName = await getRegistryName();
|
const registryName = await getRegistryName();
|
||||||
const packages = await getPackages();
|
const packages = await getPackages();
|
||||||
|
|
||||||
try {
|
if (registryName) {
|
||||||
await cleanRegistry(registryName, packages);
|
try {
|
||||||
} catch (e) {
|
await cleanRegistry(registryName, packages);
|
||||||
core.info(`[warning] ${(e as any).stack}`);
|
} catch (e) {
|
||||||
|
core.info(`[warning] ${(e as any).stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -71,7 +73,7 @@ async function run() {
|
|||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
||||||
async function getRegistryName(): Promise<string> {
|
async function getRegistryName(): Promise<string | null> {
|
||||||
const globber = await glob.create(`${paths.index}/**/.last-updated`, { followSymbolicLinks: false });
|
const globber = await glob.create(`${paths.index}/**/.last-updated`, { followSymbolicLinks: false });
|
||||||
const files = await globber.glob();
|
const files = await globber.glob();
|
||||||
if (files.length > 1) {
|
if (files.length > 1) {
|
||||||
@ -79,6 +81,9 @@ async function getRegistryName(): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const first = files.shift()!;
|
const first = files.shift()!;
|
||||||
|
if (!first) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return path.basename(path.dirname(first));
|
return path.basename(path.dirname(first));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user