deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

fs/mod.ts ensureSymlinkSync throws error with code EEXIST

Open tracker1 opened this issue 3 years ago • 1 comments

Describe the bug

Steps to Reproduce

  1. Create a directory of ./dir_src.
  2. Create and run the script below
import { ensureSymlinkSync } from "https://deno.land/[email protected]/fs/mod.ts";

ensureSymlinkSync('./dir_src', './dir_dest');
ensureSymlinkSync('./dir_src', './dir_dest');

Expected behavior

It doesn't throw an error.

Environment

  • OS: Debian Bullseye, inside docker
  • deno version: 1.21.0
  • std version: 0.154.0

** Example Error **

error: Uncaught (in promise) AlreadyExists: File exists (os error 17), symlink '/sbbs-data/backup' -> '/backup'
  Deno.symlinkSync(src, dest, options);
       ^
    at Object.opSync (deno:core/01_core.js:172:12)
    at Object.symlinkSync (deno:runtime/js/30_fs.js:355:10)
    at ensureSymlinkSync (https://deno.land/[email protected]/fs/ensure_symlink.ts:48:8)
    at ensureSymlinkSync (file:///sbbs/scripts/init.ts:12:5)
    at checkAll (file:///sbbs/scripts/init.ts:128:5)

tracker1 avatar Sep 06 '22 00:09 tracker1

Not sure if it matters, but the src directory is under a Docker volume mount, and the destination is inside the container... not sure if that makes a difference... should probably trap and swallow that error code anyway.

tracker1 avatar Sep 06 '22 16:09 tracker1