Skip to content

Commit

Permalink
Add some debug prints to solve #314
Browse files Browse the repository at this point in the history
  • Loading branch information
andreafrancia committed Nov 9, 2023
1 parent 547eb42 commit 005a363
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
6 changes: 5 additions & 1 deletion trashcli/restore/info_dir_searcher.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -17,6 +20,7 @@ def all_file_in_info_dir(self,
): # 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)

Expand Down
6 changes: 4 additions & 2 deletions trashcli/restore/info_files.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from trashcli.restore.file_system import ListingFileSystem
from trashcli.trash import debug_print


class InfoFiles:
Expand All @@ -14,9 +15,10 @@ def all_info_files(self, path):
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)
12 changes: 8 additions & 4 deletions trashcli/restore/trash_directories.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -65,6 +68,7 @@ def __init__(self,

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:
Expand Down
8 changes: 8 additions & 0 deletions trashcli/trash.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 005a363

Please sign in to comment.