Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions pkgm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ async function query_pkgx(
}

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

async function processEntry(sourcePath: string, targetPath: string) {
Expand All @@ -367,8 +368,18 @@ async function mirror_directory(dst: string, src: string, prefix: string) {
if (existsSync(targetPath)) {
await Deno.remove(targetPath);
}
// Create a hard link for files
await Deno.link(sourcePath, targetPath);
try {
await Deno.link(sourcePath, targetPath);
} catch {
if (!warned_copy_fallback) {
console.warn(
"%c! hardlinking failed (possibly cross-device?), falling back to file copy",
"color:yellow",
);
warned_copy_fallback = true;
}
await Deno.copyFile(sourcePath, targetPath);
}
} else if (fileInfo.isSymlink) {
// Recreate symlink in the target directory
const linkTarget = await Deno.readLink(sourcePath);
Expand Down
Loading