forked from TagStudioDev/TagStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expanded file deletion/trashing (TagStudioDev#409)
* feat: send deleted files to system trash This refactors the file deletion code to send files to the system trash instead of performing a hard deletion. It also fixes deleting video files and GIFs loaded in the Preview Panel. * feat(ui): add file deletion confirmation boxes * feat(ui): add delete file menu option + shortcut * ui: update file deletion message boxes * fix(ui): same default confirm button on win/mac - Make "Yes" the default choice in the delete file modal for both Windows and macOS (Linux untested) - Change status messages to be more broad, since they also are displayed when cancelling the operation * ui: show perm deletion warning on all platforms
- Loading branch information
1 parent
0bf7511
commit fb4a1b5
Showing
10 changed files
with
298 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ pydub==0.25.1 | |
mutagen==1.47.0 | ||
numpy==1.26.4 | ||
ffmpeg-python==0.2.0 | ||
Send2Trash==1.8.3 | ||
vtf2img==0.1.0 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (C) 2024 Travis Abendshien (CyanVoxel). | ||
# Licensed under the GPL-3.0 License. | ||
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio | ||
|
||
import logging | ||
from pathlib import Path | ||
|
||
from send2trash import send2trash | ||
|
||
logging.basicConfig(format="%(message)s", level=logging.INFO) | ||
|
||
|
||
def delete_file(path: str | Path) -> bool: | ||
"""Sends a file to the system trash. | ||
Args: | ||
path (str | Path): The path of the file to delete. | ||
""" | ||
_path = Path(path) | ||
try: | ||
logging.info(f"[delete_file] Sending to Trash: {_path}") | ||
send2trash(_path) | ||
return True | ||
except PermissionError as e: | ||
logging.error(f"[delete_file][ERROR] PermissionError: {e}") | ||
except FileNotFoundError: | ||
logging.error(f"[delete_file][ERROR] File Not Found: {_path}") | ||
except Exception as e: | ||
logging.error(e) | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.