Open arthursw opened 10 months ago
Note: I was able to find the trashed file by searching for the newest files in my computer: find /data/amasson/nas-stk -mtime -1 -ls
This pointed me to /data/amasson/nas-stk/.Trash-1005/files
.
You are using an old version of trash-cli. Please uninstall trash-cli and reinstall using pip install trash-cli
.
It's important to use pip
because apt
or apt-get
are not able to install an updated version of trash-cli.
If the problem persists update me adding another comment here.
I iused trash-cli version 0.23.9.23 ; what's the latest one?
Yes, it is a recent version.
Can you please run
amasson@niseko:/data/amasson/nas-stk/amasson/test$ touch test
amasson@niseko:/data/amasson/nas-stk/amasson/test$ trash-put test
amasson@niseko:/data/amasson/nas-stk/amasson/test$ trash-list
amasson@niseko:/data/amasson/nas-stk/amasson/test$ trash-restore
There are some symlink in the components of /data/amasson/nas-stk/amasson/test
?
Here is the test:
amasson@niseko:/data/amasson/nas-stk/amasson/test$ touch test
amasson@niseko:/data/amasson/nas-stk/amasson/test$ trash-put test
amasson@niseko:/data/amasson/nas-stk/amasson/test$ trash-list
2023-10-30 11:23:38 /data/users/nnunet/models/nnUNet
2023-10-25 15:03:12 /data/amasson/evaluation/TheseJLB/Session/Switch 4/27_10_2017/dcm
2023-10-25 15:03:20 /data/amasson/evaluation/TheseJLB/Session/Switch 4/27_10_2017/nifti
2023-10-26 11:54:55 /data/amasson/evaluation/TheseJLB/Session.zip
2023-10-25 15:03:14 /data/amasson/evaluation/TheseJLB/Session/Switch 4/27_10_2017/dcm2
2023-10-25 15:03:06 /data/amasson/evaluation/TheseJLB/Session/Switch 4/27_10_2017/0010177_26332_3D_FLAIR_3D_FLAIR_FS_OFSEP_nii.zip
2023-10-25 15:02:59 /data/amasson/evaluation/TheseJLB/Session/Switch 4/27_10_2017/0010177_26332_3D_FLAIR_3D_FLAIR_FS_OFSEP_nii
amasson@niseko:/data/amasson/nas-stk/amasson/test$ trash-restore
No files trashed from current dir ('/data/amasson/nas-stk/amasson/test')
Note that /data/amasson/nas-stk
is a mounted volume with the following command:
sudo mount -t cifs -o username=amasson,domain=AD,uid=$(id -u),gid=$(id -g),forceuid,forcegid //domain.address.fr/path /data/amasson/nas-stk/
Unfortunately I didn't have never tested directly CIFS. Maybe I can do something if I receive enough information.
Please search in the volume trashdirs:
find /data/amasson/nas-stk/.Trash/$(id -u) -ls
find /data/amasson/nas-stk/.Trash-$(id -u) -ls
There should be two files:
Please check also the permission of the trash directories:
ls -lad /data/amasson/nas-stk/{Trash,Trash-$(id -u)}/
Thanks
There are tons of files in the /data/amasson/nas-stk/.Trash-$(id -u)
directory. ; but the first path (/data/amasson/nas-stk/.Trash/$(id -u)
) does not exist.
Here is the content of /data/amasson/nas-stk/.Trash-$(id -u)/info/test.trashinfo
:
[Trash Info]
Path=amasson/test/test
DeletionDate=2023-09-28T11:11:20
The file /data/amasson/nas-stk/.Trash-1005/files/test
exists.
The permissions: drwxr-xr-x 2 amasson amasson 0 févr. 4 2022 /data/amasson/nas-stk/.Trash-1005/
.
Thanks!
Please check if any of these command is able to see your trashed file:
$ trash-restore /data/amasson/nas-stk/amasson/test
$ trash-restore /data/amasson/nas-stk/amasson
$ trash-restore /data/amasson/nas-stk
$ trash-restore /data/amasson
And try to execute these python commands:
$ cd /data/amasson/nas-stk/amasson/test
$ python -c "import os; print(os.path.realpath(os.curdir))"
$ python -c "import os; print(os.path.normpath(os.path.join(os.path.realpath(os.curdir) + os.path.sep, '')))"
Thank you
(base) amasson@niseko:~$ trash-restore /data/amasson/nas-stk/amasson/test
No files trashed from current dir ('/home/amasson')
(base) amasson@niseko:~$ cd /data/amasson/
(base) amasson@niseko:/data/amasson$ trash-restore /data/amasson/nas-stk/amasson/test
No files trashed from current dir ('/data/amasson')
(base) amasson@niseko:/data/amasson$ trash-restore /data/amasson/nas-stk/amasson/
No files trashed from current dir ('/data/amasson')
(base) amasson@niseko:/data/amasson$ trash-restore /data/amasson/nas-stk
No files trashed from current dir ('/data/amasson')
(base) amasson@niseko:/data/amasson$ trash-restore /data/amasson
0 2023-10-25 15:02:59 /data/amasson/evaluation/TheseJLB/Session/Switch 4/27_10_2017/0010177_26332_3D_FLAIR_3D_FLAIR_FS_OFSEP_nii
1 2023-10-25 15:03:06 /data/amasson/evaluation/TheseJLB/Session/Switch 4/27_10_2017/0010177_26332_3D_FLAIR_3D_FLAIR_FS_OFSEP_nii.zip
2 2023-10-25 15:03:12 /data/amasson/evaluation/TheseJLB/Session/Switch 4/27_10_2017/dcm
3 2023-10-25 15:03:14 /data/amasson/evaluation/TheseJLB/Session/Switch 4/27_10_2017/dcm2
4 2023-10-25 15:03:20 /data/amasson/evaluation/TheseJLB/Session/Switch 4/27_10_2017/nifti
5 2023-10-26 11:54:55 /data/amasson/evaluation/TheseJLB/Session.zip
What file to restore [0..5]:
Exiting
(base) amasson@niseko:/data/amasson$ cd /data/amasson/nas-stk/amasson/test
(base) amasson@niseko:/data/amasson/nas-stk/amasson/test$ python -c "import os; print(os.path.realpath(os.curdir))"
/data/amasson/nas-stk/amasson/test
(base) amasson@niseko:/data/amasson/nas-stk/amasson/test$ python -c "import os; print(os.path.normpath(os.path.join(os.path.realpath(os.curdir) + os.path.sep, '')))"
/data/amasson/nas-stk/amasson/test
(base) amasson@niseko:/data/amasson/nas-stk/amasson/test$
Thank you
Sorry, but I'm not still able to figure out the problem.
The file is going to the "(2)" trash dir, $topdir/.Trash-$uid (by the specs: https://specifications.freedesktop.org/trash-spec/trashspec-latest.html) .
It seems that you have this directory and its name is /data/amasson/nas-stk/.Trash-1005
You also have the trashed file in it
/data/amasson/nas-stk/.Trash-1005/info/test.trashinfo
/data/amasson/nas-stk/.Trash-1005/files/test
The trashinfo seems well formed:
[Trash Info]
Path=amasson/test/test
DeletionDate=2023-09-28T11:11:20
It's seems all ok.
I have prepared a version with some additional debug message that can help me to understand the situation. Can you install it and run it:
# remove previous version
pip uninstall trash-cli
# install the debug version
pip install git+https://github.com/andreafrancia/trash-cli@debug.314
# run
trash-put --version
cd /data/amasson/nas-stk/amasson/test
touch test
trash-put test
trash-list --trash-dirs
# for this step is important to enable the debug:
TRASHCLI_DEBUG=1 trash-restore
The debug print I have added are expressed in this patch
commit 005a363181fd9a3802a18f343962c7f1336fe2ea
Author: Andrea Francia <260852+andreafrancia@users.noreply.github.com>
Date: Thu Nov 9 12:00:07 2023 +0100
Add some debug prints to solve https://github.com/andreafrancia/trash-cli/issues/314
diff --git a/trashcli/restore/info_dir_searcher.py b/trashcli/restore/info_dir_searcher.py
index 12577bc..215aa23 100644
--- a/trashcli/restore/info_dir_searcher.py
+++ b/trashcli/restore/info_dir_searcher.py
@@ -1,7 +1,10 @@
-from typing import NamedTuple, Iterable, Optional
+from typing import Iterable
+from typing import NamedTuple
+from typing import Optional
from trashcli.restore.info_files import InfoFiles
from trashcli.restore.trash_directories import TrashDirectories
+from trashcli.trash import debug_print
class InfoDirSearcher:
@@ -17,6 +20,7 @@ class InfoDirSearcher:
): # type: (...) -> Iterable[FileFound]
for trash_dir_path, volume in self.trash_directories.list_trash_dirs(
trash_dir_from_cli):
+ debug_print(">>>> found trash dir: %s" % trash_dir_path)
for type, path in self.info_files.all_info_files(trash_dir_path):
yield FileFound(type, path, volume)
diff --git a/trashcli/restore/info_files.py b/trashcli/restore/info_files.py
index 4cf1938..f0bf0a7 100644
--- a/trashcli/restore/info_files.py
+++ b/trashcli/restore/info_files.py
@@ -1,6 +1,7 @@
import os
from trashcli.restore.file_system import ListingFileSystem
+from trashcli.trash import debug_print
class InfoFiles:
@@ -14,9 +15,10 @@ class InfoFiles:
info_dir = os.path.join(norm_path, 'info')
try:
for info_file in self.fs.list_files_in_dir(info_dir):
+ debug_print(">>>> info_file: %s" % info_file)
if not os.path.basename(info_file).endswith('.trashinfo'):
yield ('non_trashinfo', info_file)
else:
yield ('trashinfo', info_file)
- except OSError: # when directory does not exist
- pass
+ except OSError as e: # when directory does not exist
+ debug_print(">>>> exception: %s" % e)
diff --git a/trashcli/restore/trash_directories.py b/trashcli/restore/trash_directories.py
index 4f1c180..73f5661 100644
--- a/trashcli/restore/trash_directories.py
+++ b/trashcli/restore/trash_directories.py
@@ -1,14 +1,17 @@
# Copyright (C) 2007-2023 Andrea Francia Trivolzio(PV) Italy
-from abc import abstractmethod, ABCMeta
+from abc import ABCMeta
+from abc import abstractmethod
+from typing import Optional
import six
-from typing import Optional
from trashcli.fstab.volume_of import VolumeOf
from trashcli.fstab.volumes import Volumes
from trashcli.lib.environ import Environ
-from trashcli.lib.trash_dirs import (
- volume_trash_dir1, volume_trash_dir2, home_trash_dir)
+from trashcli.lib.trash_dirs import home_trash_dir
+from trashcli.lib.trash_dirs import volume_trash_dir1
+from trashcli.lib.trash_dirs import volume_trash_dir2
+from trashcli.trash import debug_print
@six.add_metaclass(ABCMeta)
@@ -65,6 +68,7 @@ class TrashDirectories1:
def all_trash_directories(self):
volumes_to_check = self.volumes.list_mount_points()
+ debug_print(">>>> volumes_to_check: %s" % volumes_to_check)
for path1, volume1 in home_trash_dir(self.environ, self.volumes):
yield path1, volume1
for volume in volumes_to_check:
diff --git a/trashcli/trash.py b/trashcli/trash.py
index db1a088..30f61ee 100644
--- a/trashcli/trash.py
+++ b/trashcli/trash.py
@@ -1,3 +1,11 @@
# Copyright (C) 2007-2011 Andrea Francia Trivolzio(PV) Italy
version = '0.23.9.23'
+
+
+def debug_print(msg):
+ import os
+ import sys
+ if os.environ.get('TRASHCLI_DEBUG') == '1':
+ print(msg, file=sys.stderr)
+
Describe the bug I remove a file located in a remote cifs volume with
trash /remote_volume_path/test_file.txt
, and when I trytrash-restore
it says:No files trashed from current dir ('/remote_volume_path/')
.trash-cli version 0.23.9.23
Are you using the latest version of trash-cli? Yes
Have you tried if the bug is present in the latest version of trash-cli? Yes
Operating system: Ubuntu 18.04.6 LTS
To Reproduce
trash-list
does not help either (showing trashed files from other locations).Expected behavior Trash cli should show the file I just trashed.
Volumes detail