Skip to content

Commit 6cb56cd

Browse files
committed
Fall back to making a regular copy if hard linking fails (it is pretty typical for Linux distributions to setup home directories on a separate volume).
1 parent e3934de commit 6cb56cd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkgm.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,14 @@ async function mirror_directory(dst: string, src: string, prefix: string) {
367367
if (existsSync(targetPath)) {
368368
await Deno.remove(targetPath);
369369
}
370-
// Create a hard link for files
371-
await Deno.link(sourcePath, targetPath);
370+
try {
371+
// Create a hard link for files
372+
await Deno.link(sourcePath, targetPath);
373+
} 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).
376+
await Deno.copyFile(sourcePath, targetPath);
377+
}
372378
} else if (fileInfo.isSymlink) {
373379
// Recreate symlink in the target directory
374380
const linkTarget = await Deno.readLink(sourcePath);

0 commit comments

Comments
 (0)