If the dedup-files source file ends up in the list of destinations, bedup fails in some confusing ways. The fix I'd prefer: if the source file appears in the destination list, then silently remove it. If this would be unsafe, it might be better to exit with an error.
Here's what happens. Start with some identical files:
$ ls -la foo.*
-rw-r--r-- 1 ross ross 10856343 Jan 13 18:43 foo.0
-rw-r--r-- 1 ross ross 10856343 Jan 13 18:43 foo.1
-rw-r--r-- 1 ross ross 10856343 Jan 13 18:43 foo.2
-rw-r--r-- 1 ross ross 10856343 Jan 13 18:43 foo.3
Now, I want to dedup them with source foo.2. But I am lazy, so I try this:
$ sudo ~/bin/bedup dedup-files foo.2 foo.*
You need to run this command as root.
Surprising error, so I tried to do it more carefully:
$ sudo ~/bin/bedup dedup-files foo.2 foo.0 foo.1 foo.3
Traceback (most recent call last):
File "/home/ross/bin/bedup", line 9, in <module>
load_entry_point('bedup==0.9.0', 'console_scripts', 'bedup')()
File "/root/.local/lib/python2.7/site-packages/bedup/__main__.py", line 483, in script_main
sys.exit(main(sys.argv))
File "/root/.local/lib/python2.7/site-packages/bedup/__main__.py", line 472, in main
return args.action(args)
File "/root/.local/lib/python2.7/site-packages/bedup/__main__.py", line 54, in cmd_dedup_files
return dedup_same(args.source, args.dests, args.defrag)
File "/root/.local/lib/python2.7/site-packages/bedup/dedup.py", line 90, in dedup_same
dest_fds = [os.open(dname, os.O_RDWR) for dname in dests]
OSError: [Errno 13] Permission denied: 'foo.0'
This happens because bedup's use of the immutable bit couldn't get cleaned up:
If the dedup-files source file ends up in the list of destinations, bedup fails in some confusing ways. The fix I'd prefer: if the source file appears in the destination list, then silently remove it. If this would be unsafe, it might be better to exit with an error.
Here's what happens. Start with some identical files:
Now, I want to dedup them with source foo.2. But I am lazy, so I try this:
Surprising error, so I tried to do it more carefully:
This happens because bedup's use of the immutable bit couldn't get cleaned up:
"chattr -i" fixes that, of course.
Ross