sunaku / dasht

💁 Search API docs offline, in terminal or browser
https://sunaku.github.io/dasht/man
827 stars 26 forks source link

Got issue while installing JavaScript dashset : rm no such file or directory. #62

Open edi9999 opened 2 months ago

edi9999 commented 2 months ago

It seems like some unicode character in the Javascript.docset causes an issue in the install script.

Reproduce with this script :

 \rm -rf ~/.local/share/dasht/docsets/JavaScript.tgz ~/.local/share/dasht/docsets/JavaScript.docset/ && dasht-docsets-install -f ^JavaScript$

Gives following output :

        JavaScript

--2024-09-17 09:42:50--  https://kapeli.com/feeds/JavaScript.tgz
Resolving kapeli.com (kapeli.com)... 23.92.22.81
Connecting to kapeli.com (kapeli.com)|23.92.22.81|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 250885359 (239M) [application/x-tar]
Saving to: ‘/home/edgar/.local/share/dasht/docsets/JavaScript.tgz’

245000K .....                                                 100% 9.75T=16s

2024-09-17 09:43:07 (14.8 MB/s) - ‘/home/edgar/.local/share/dasht/docsets/JavaScript.tgz’ saved [250885359/250885359]

removed '/home/edgar/.local/share/dasht/docsets/JavaScript.docset/Contents/Resources/Documents/developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/aside_â'$'\302\200\302\224''_.mjs_versus_.html'
rm: cannot remove '/home/edgar/.local/share/dasht/docsets/JavaScript.docset/Contents/Resources/Documents/developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/aside_â\302\200\302\224_.mjs_versus_.html': No such file or directory
edi9999 commented 2 months ago

The issue seems to happen in the following command (dasht-docsets-extract) :

  { find "$want" -print
    tar -t -f "$tgz" -z | sed -e "s|^[^/]*|$want|" -e 's|/$||'
  } | sort -r | uniq -c | sed -n 's/^ *1 //p' | while read -r arg; do
      if test -d "$arg"
      then rmdir "$arg"
      else rm -v "$arg"
      fi
  done
edi9999 commented 2 months ago

The rm here is the one that fails.

edi9999 commented 2 months ago

Changing it to this worked for me :

  # remove any stale files that were left behind by the previous extraction
  { find "$want" -print
    tar -t -f "$tgz" -z | sed -e "s|^[^/]*|$want|" -e 's|/$||'
  } | sort -r | uniq -c | sed -n 's/^ *1 //p' | while read -r arg; do
      if test -d "$arg"
      then rmdir "$arg"
      elif test -f "$arg"
      then
          rm -v "$arg"
      fi
  done