-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: port file trashing (#409) to sql
- Loading branch information
Showing
6 changed files
with
201 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (C) 2025 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