lumeland / lume

🔥 Static site generator for Deno 🦕
https://lume.land
MIT License
1.85k stars 85 forks source link

lume -s, Fail to copy file to where the path once was a directory #626

Closed iacore closed 1 month ago

iacore commented 3 months ago

Version

about the latest

Platform

Linux

What steps will reproduce the bug?

  1. site.copy('public')
  2. deno task serve &
    # wait for server to launch
    cd public/
    mkdir b.md
    touch b.md/b.md
    rm -r b.md; touch b.md

How often does it reproduce? Is there a required condition?

100% methinks

What is the expected behavior?

There should be no error.

What do you see instead?

ERROR Failed to copy file: /b.md/b.md: Not a directory (os error 20): readfile '/home/user/__site__/public/b.md/b.md'

Additional information

workaround: run deno task serve again.

oscarotero commented 3 months ago

Do you mean this error should be catched and showed in the terminal but without exit?

iacore commented 3 months ago

Do you mean this error should be cached and showed in the terminal but without exit?

ohhh sorry i forgot to fill in the field; it should not be an user-facing error.

let me explain why the error happens

  1. b.md/b.md is created
  2. b.md/b.md is deleted, but b.md/ isn't deleted
  3. b.md is created

proper behavior: when Lume sees empty folder it should overwrite it

this may mess with site.copy('empty_directory'); not sure who would want to put an empty directory in the output though.

oscarotero commented 1 month ago

This has been fixed and will be released in Lume 2.3. From now on, if a file is removed and its folder is empty, it's removed too.