ShuguangSun / find-dupes-dired

Find dupes and handle them in dired-mode.
GNU General Public License v2.0
5 stars 2 forks source link

Can't delete file #2

Open stardiviner opened 3 years ago

stardiviner commented 3 years ago

I execute command find-dupes-dired, then press d, then press x to execute. The delete marked file is not really deleted.

ShuguangSun commented 3 years ago

What is the Emacs version and system?

After any do (e.g., d and x), the dired buffer will not auto update. Try g (for find-dupes-dired--rerun) to find out whether deleted files still exists?

stardiviner commented 3 years ago

Yes, I did g, and also tried kill the result buffer, and repeat the find-dupes-dired command process again. Still same. Can't delete. Is there anyway to debug?

ShuguangSun commented 3 years ago
  1. Go the directory of the file you want to delete, and try d and x in real dired-mode to find out whether you have the authorization of deletion.
  2. Update the pacakge to the most recent version, and (setq find-dupes-dired-verbose t). It will put some information in the message buffer, for example, the line of "command line: ". Please try it in shell to see whether the output is desired. Note, the filename should not be surounded with '. You can compare find-dupes-dired-ls-option with find-dired-ls-option and they should be simlilar but a U for not sorting.
stardiviner commented 3 years ago

I'm sure I can delete those file if not in Emacs.

Here is the output:

  /home/stardiviner/Downloads/:
  fdupes  -r /home/stardiviner/Downloads/ -q | xargs -d "\n" ls -dilsbU
 '':  No such file       or directory
  3326841    0 -rw-rw-r-- 1 stardiviner stardiviner       0  5月 18  2014 /home/stardiviner/Downloads/Contacts\ vcard/vCards/Coworkers.vcf
  3359039    0 -rw-rw-r-- 1 stardiviner stardiviner       0  5月 18  2014 /home/stardiviner/Downloads/Contacts\ vcard/vCards/Hacker.vcf
  3326933    0 -rw-rw-r-- 1 stardiviner stardiviner       0  5月 18  2014 /home/stardiviner/Downloads/Contacts\ vcard/vCards/Family.vcf
  3357568    0 -rw-rw-r-- 1 stardiviner stardiviner       0  5月 18  2014 /home/stardiviner/Downloads/Contacts\ vcard/vCards/Friends.vcf
  4594960    0 -rw-r--r-- 1 stardiviner stardiviner       0 12月  2 21:12 /home/stardiviner/Downloads/china-privacy-data-detect-website/website/src/App.css
  3472720    0 -rw-r--r-- 1 stardiviner stardiviner       0  1月  5 22:25 /home/stardiviner/Downloads/.thumbnails/Neural\ Network\ Architectures-oJNHXPs0XDk.jpg
  3532604    0 -rw-r--r-- 1 stardiviner stardiviner       0  1月 24 16:41 /home/stardiviner/Downloads/.thumbnails/Oz\ live\ code\ reloading\ demo-yUTxm29fjT4.jpg
  3325952    4 -rw------- 1 stardiviner stardiviner     122  5月 18  2013 /home/stardiviner/Downloads/Contacts\ vcard/Exported\ contacts\ 1/WARNING_README.txt
  3359162    4 -rw-rw-r-- 1 stardiviner stardiviner     122  7月  6  2014 /home/stardiviner/Downloads/Contacts\ vcard/vCards/WARNING_README.txt
  3328901  956 -rw-r--r-- 1 stardiviner stardiviner  976870  1月 18 14:56 /home/stardiviner/Downloads/Telegram\ Desktop/IMG_9001.mp4
  3333032  956 -rw-r--r-- 1 stardiviner stardiviner  976870  1月 28 13:00 /home/stardiviner/Downloads/Telegram\ Desktop/IMG_9001\ (2).mp4

I toggled verbose option. Still can't figure out the problem reason. Here is the output in *Messages*:

Truncate long lines disabled
find-dupes-dired *Dired: Dupes* finished.
Delete TelegramDesktop/IMG_9001(2).mp4 (y or n) y
Deleting...done
Truncate long lines enabled
find-dupes-dired *Dired: Dupes* finished.
Quit [2 times]
t
Delete TelegramDesktop/IMG_9001(2).mp4 (y or n) y
Deleting...done
dir: /home/stardiviner/Downloads/
args: 
command line: fdupes  -r /home/stardiviner/Downloads/ -q | xargs -d "\n" ls -dilsbU
Truncate long lines disabled
find-dupes-dired *Dired: Dupes* finished.
Quit [2 times]
find-dupes-dired-rerun-toggle-flag: Wrong type argument: find-dupes-dired-search-list, nil
Quit
find-dupes-dired-program: fdupes
dir: /home/stardiviner/Downloads/
args: 
command line: fdupes  -r /home/stardiviner/Downloads/ -q | xargs -d "\n" ls -dilsbU
Truncate long lines enabled
error in process filter: Args out of range: #<buffer *Dired: Dupes*>, 105, 109 [2 times]
find-dupes-dired *Dired: Dupes* finished.
Mark set [3 times]
Mark saved where search started
Mark set

I installed find-dired package. but have not found the find-dired-ls-option. But I found another option find-ls-option in find-dired. It's value is ("-ls" . "-dilsb"). And find-dupes-dired-ls-option value is ("-q | xargs -d \"\\n\" ls -dilsbU" . "-dilsbU") instead.

stardiviner commented 3 years ago

The upper is tried after I upgraded to latest version in MELPA today.

    Version: 20210202.1333
     Commit: 0e555047e27b0197d003f758307ef49c08a1c2ae
ShuguangSun commented 3 years ago

'': No such file or directory This is strange. The empty should be filtered. I'll check the code later.

"Delete TelegramDesktop/IMG_9001(2).mp4 (y or n) " the SPACE in the directory and filename is omitted as well. You may need to tune the ls option.

ShuguangSun commented 3 years ago

Could you help try (setq find-dupes-dired-ls-option '("-q | xargs -d \"\\n\" ls -lsU" . "-dilsbU"))?

ShuguangSun commented 3 years ago

'': No such file or directory 的问题可能出在下边这个地方,

(while (re-search-forward "^[ ]\*ls: cannot access" nil t)
                  (save-excursion
                    (delete-region (point) (progn (forward-visible-line 0) (point))))
                  (delete-region (point) (progn (end-of-visible-line) (+ (point) 1))))
stardiviner commented 3 years ago

试了你上面的 setq 选项。还是一样的报错。

stardiviner commented 3 years ago

确实是有 cannot access 的报错。我用命令行也有这个报错。有没有办法忽略报错,或者绕过?

stardiviner commented 3 years ago
➜  Downloads fdupes  -r /home/stardiviner/Downloads/ -q | xargs -d "\n" ls -dilsbU
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
ls: cannot access '': No such file or directory
3326841    0 -rw-rw-r-- 1 stardiviner stardiviner       0  5月 18  2014 /home/stardiviner/Downloads/Contacts\ vcard/vCards/Coworkers.vcf
3359039    0 -rw-rw-r-- 1 stardiviner stardiviner       0  5月 18  2014 /home/stardiviner/Downloads/Contacts\ vcard/vCards/Hacker.vcf
3326933    0 -rw-rw-r-- 1 stardiviner stardiviner       0  5月 18  2014 /home/stardiviner/Downloads/Contacts\ vcard/vCards/Family.vcf
3357568    0 -rw-rw-r-- 1 stardiviner stardiviner       0  5月 18  2014 /home/stardiviner/Downloads/Contacts\ vcard/vCards/Friends.vcf
stardiviner commented 3 years ago

但是我 fdupes -r Downloads 又是没问题的。应该是ls命令选项不兼容

hjudt commented 3 years ago

Your hack won't filter any occurrences of those ls: cannot access '': No such file or directory appearing in the user's native language. You would have to set LC_ALL=C to force a locale.

Maybe a better approach would be to just pipe ls 2>/dev/null. For example, this fixes it for me though my locale is not English: (setq find-dupes-dired-ls-option '("-q | xargs -d \"\n\" ls -lsU 2>/dev/null" . "-dilsbU"))

ShuguangSun commented 3 years ago

Thanks @hjudt . I would add it to default darwan find-dupes-dired-ls-option.

hjudt commented 3 years ago

I forgot to mention, I am using a Linux system, not Apple. But it probably will work for Apple and other Unix-like systems too.

hjudt commented 3 years ago

Also, sticking with ls -dilsbU instead of ls -lsU will be ok, I only tried your suggestion in some comment above.

hjudt commented 3 years ago

Using this, you can also remove your workaround https://github.com/ShuguangSun/find-dupes-dired/blob/main/find-dupes-dired.el#L138.

ShuguangSun commented 3 years ago

It is great! Thanks.