mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-25 18:25:35 +02:00
making progress
This commit is contained in:
24
backend/src/torrent/utils.py
Normal file
24
backend/src/torrent/utils.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from config import BasicConfig
|
||||
from torrent.schemas import Torrent
|
||||
|
||||
|
||||
def list_files_recursively(path: Path = Path(".")) -> list[Path]:
|
||||
files = list(path.glob("**/*"))
|
||||
logging.debug(f"Found {len(files)} entries via glob")
|
||||
valid_files = []
|
||||
for x in files:
|
||||
if x.is_dir():
|
||||
logging.debug(f"'{x}' is a directory")
|
||||
elif x.is_symlink():
|
||||
logging.debug(f"'{x}' is a symlink")
|
||||
else:
|
||||
valid_files.append(x)
|
||||
logging.debug(f"Returning {len(valid_files)} files after filtering")
|
||||
return valid_files
|
||||
|
||||
|
||||
def get_torrent_filepath(torrent: Torrent):
|
||||
return BasicConfig().torrent_directory / torrent.title
|
||||
Reference in New Issue
Block a user