Skip to content

fix: folders with names of unlinked entries are linked #1027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/tagstudio/qt/helpers/file_deleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def delete_file(path: str | Path) -> bool:
"""
_path = Path(path)
try:
if _path.is_dir():
return False
logger.info(f"[delete_file] Sending to Trash: {_path}")
send2trash(_path)
return True
Expand Down
6 changes: 4 additions & 2 deletions src/tagstudio/qt/helpers/file_opener.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ def set_filepath(self, filepath: str | Path):

def open_file(self):
"""Open the file in the default application."""
open_file(self.filepath)
if Path(self.filepath).is_file():
open_file(self.filepath)

def open_explorer(self):
"""Open the file in the default file explorer."""
open_file(self.filepath, file_manager=True)
if Path(self.filepath).is_file():
open_file(self.filepath, file_manager=True)


class FileOpenerLabel(QLabel):
Expand Down
2 changes: 1 addition & 1 deletion src/tagstudio/qt/widgets/preview/file_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def update_stats(self, filepath: Path | None = None, stats: FileAttributeData |

# Attempt to populate the stat variables
ext_display = ext.upper()[1:] or filepath.stem.upper()
if filepath:
if filepath and filepath.is_file():
try:
file_size = format_size(filepath.stat().st_size)

Expand Down
4 changes: 2 additions & 2 deletions src/tagstudio/qt/widgets/thumb_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ def fetch_cached_image(folder: Path):
if not image:
image = (
render_unlinked((adj_size, adj_size), pixel_ratio)
if not filepath.exists()
if not filepath.exists() or filepath.is_dir()
else render_default((adj_size, adj_size), pixel_ratio)
)
render_mask_and_edge = False
Expand Down Expand Up @@ -1290,7 +1290,7 @@ def fetch_cached_image(folder: Path):
if not image:
image = (
render_unlinked((512, 512), 2)
if not filepath.exists()
if not filepath.exists() or filepath.is_dir()
else render_default((512, 512), 2)
)
render_mask_and_edge = False
Expand Down