trash-cli
trash-cli copied to clipboard
trash-put: --force-another-volume (was Possibility of change the path of trash should be there! :()
Possibility of change the path of trash should be there! :(
I don't understand, how people can use it without this feature. Is possible to add? :)
Originally posted by @ShaiMagal in https://github.com/andreafrancia/trash-cli/issues/125#issuecomment-1345724037
You can use one of the following:
- the
--trash-diroption available in manytrash-*commands. - the XDG_DATA_HOME environment variable
You can use one of the following:
- the
--trash-diroption available in manytrash-*commands.- the XDG_DATA_HOME environment variable
Ah, now I understand. I had older version from apt. Now I have latest and "--trash-dir" is in "-h" option.
BUT not useful :( trash-put --trash-dir /srv/backup/tmp_only/trash a/ -vvv trash-put: volume of file: / trash-put: trying trash dir: /srv/backup/tmp_only/trash from volume: /srv/backup trash-put: won't use trash dir /srv/backup/tmp_only/trash because its volume (/srv/backup) in a different volume than a/ (/) trash-put: cannot trash directory 'a/'
Why it must be same volume?
At the present trash-put does not allow trash between volumes because it does not handle (yet) some situation that can happen when moving files, and especially, directories between volumes.
These situations are:
- what happen if file trashed is larger that the destination volume free space?
- what happen if the moving of a directory would be stopped because you have a file with the proper permission: you will having the directory split in two places.
Regards
Ah, bad :( It's not usefull for me, because one volume we have not too much free space and we would like to delete (move to trash) to another volume (backup volume)... (our volume backup is used for this - now we use "mv" or "rsync" command - but this trash command will save us any time)
Is possible to add any "--force-another-volume" option or something like that to next release? This option will ignore message for deleting to another volume, and it will in full responsibility for each, who will use this option..
What do you think?
You can try to remove the limitation using this patch. Beware that I haven't tested it so there maybe other problems that I can not think of right now.
The code below is not tested, using it you (or any other person using it) accept the risk of data deletion or any other damage that can caused that this code. This code should be accompanied by this disclaimer.
diff --git a/trashcli/put/gate_impl.py b/trashcli/put/gate_impl.py
index 19e886c..849344e 100644
--- a/trashcli/put/gate_impl.py
+++ b/trashcli/put/gate_impl.py
@@ -69,12 +69,5 @@ class SameVolumeGateImpl(GateImpl):
candidate, # type: Candidate
environ, # type: Dict[str, str]
):
- same_volume = self.trash_dir_volume.volume_of_trash_dir(
- candidate.trash_dir_path) == trashee.volume
-
- if not same_volume:
- msg_formatter = VolumeMessageFormatter()
- message = msg_formatter.format_msg(trashee, candidate, environ)
- return GateCheckResult.make_error(message)
return GateCheckResult.make_ok()
You can use also something like this:
# The code below is not tested, using it you (or any other person using it) accept the
# risk of data deletion or any other damage that can caused that this code.
# This code should be accompanied by this disclaimer.
(
set -o errexit
for i in /source-disk/*; do
rsync --archive "$i" /destination-disk/tmp/ && rm -Rfv "$i"
done
)
Thank you, I don't want to "hardcode" anything, because I would like to update trash-cli and every update will delete this changes :( Any possibility to add it like trash-* option? (with disclaimer of course)
I will let you know as soon as I have time to think a implement a proper solution.