mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-01-29 06:10:51 +00:00
Updated to use pathlib instead of os
This commit is contained in:
committed by
Travis Abendshien
parent
e0cc0dd5a7
commit
a074912ac8
@@ -1,5 +1,5 @@
|
||||
import logging
|
||||
import os.path
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
@@ -15,12 +15,13 @@ logging.basicConfig(format="%(message)s", level=logging.INFO)
|
||||
|
||||
def delete_file(path: str | Path, callback: Callable):
|
||||
_path = str(path)
|
||||
_file = Path(_path)
|
||||
logging.info(f"Deleting file: {_path}")
|
||||
if not os.path.exists(_path):
|
||||
if not _file.exists():
|
||||
logging.error(f"File not found: {_path}")
|
||||
return
|
||||
try:
|
||||
os.remove(path)
|
||||
_file.unlink()
|
||||
callback()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
Reference in New Issue
Block a user