Skip to content

Commit 366b9b4

Browse files
authored
Implement fallback warning for hard linking failure
Add fallback warning for hard link failure in mirror_directory function, since this could cause unexpected behavior.
1 parent 6cb56cd commit 366b9b4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkgm.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ async function query_pkgx(
347347
}
348348

349349
async function mirror_directory(dst: string, src: string, prefix: string) {
350+
let warned_copy_fallback = false;
350351
await processEntry(join(src, prefix), join(dst, prefix));
351352

352353
async function processEntry(sourcePath: string, targetPath: string) {
@@ -368,11 +369,12 @@ async function mirror_directory(dst: string, src: string, prefix: string) {
368369
await Deno.remove(targetPath);
369370
}
370371
try {
371-
// Create a hard link for files
372372
await Deno.link(sourcePath, targetPath);
373373
} catch {
374-
// Fall back to a regular copy if hard linking fails (it is pretty typical
375-
// for Linux distributions to setup home directories on a separate volume).
374+
if (!warned_copy_fallback) {
375+
console.warn("%c! hardlinking failed (possibly cross-device?), falling back to file copy", "color:yellow");
376+
warned_copy_fallback = true;
377+
}
376378
await Deno.copyFile(sourcePath, targetPath);
377379
}
378380
} else if (fileInfo.isSymlink) {

0 commit comments

Comments
 (0)