Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5040f39

Browse files
Skip registry cleaning if no registry was found (Swatinem#65)
This fixes Swatinem#64. When Cargo is run in sparse-registry mode, it doesn't create ~/.cargo/registry/index/github.com-1ecc6299db9ec823/ directory.
1 parent 2055a01 commit 5040f39

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/save.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ async function run() {
3636
const registryName = await getRegistryName();
3737
const packages = await getPackages();
3838

39-
try {
40-
await cleanRegistry(registryName, packages);
41-
} catch (e) {
42-
core.info(`[warning] ${(e as any).stack}`);
39+
if (registryName) {
40+
try {
41+
await cleanRegistry(registryName, packages);
42+
} catch (e) {
43+
core.info(`[warning] ${(e as any).stack}`);
44+
}
4345
}
4446

4547
try {
@@ -71,14 +73,17 @@ async function run() {
7173

7274
run();
7375

74-
async function getRegistryName(): Promise<string> {
76+
async function getRegistryName(): Promise<string | null> {
7577
const globber = await glob.create(`${paths.index}/**/.last-updated`, { followSymbolicLinks: false });
7678
const files = await globber.glob();
7779
if (files.length > 1) {
7880
core.warning(`got multiple registries: "${files.join('", "')}"`);
7981
}
8082

8183
const first = files.shift()!;
84+
if (!first) {
85+
return null;
86+
}
8287
return path.basename(path.dirname(first));
8388
}
8489

0 commit comments

Comments
 (0)