send notification on nohardlink warning and remove

force failure
This commit is contained in:
bobokun 2022-12-19 16:50:32 -05:00
parent 3533cfb2f5
commit 99c00e3bbc
No known key found for this signature in database
GPG key ID: B73932169607D927
2 changed files with 5 additions and 4 deletions

View file

@ -518,7 +518,7 @@ class Qbt:
continue
for torrent in torrent_list:
tracker = self.config.get_tags(torrent.trackers)
has_nohardlinks = util.nohardlink(torrent["content_path"].replace(root_dir, remote_dir))
has_nohardlinks = util.nohardlink(torrent["content_path"].replace(root_dir, remote_dir), self.config.notify)
if any(tag in torrent.tags for tag in nohardlinks[category]["exclude_tags"]):
# Skip to the next torrent if we find any torrents that are in the exclude tag
continue

View file

@ -270,7 +270,7 @@ def remove_empty_directories(pathlib_root_dir, pattern):
# If a folder is passed, it will take the largest file in that folder and only check for hardlinks
# of the remaining files where the file is greater size a percentage of the largest file
# This fixes the bug in #192
def nohardlink(file):
def nohardlink(file, notify):
check = True
if os.path.isfile(file):
logger.trace(f"Checking file: {file}")
@ -284,9 +284,10 @@ def nohardlink(file):
if not sorted_files:
msg = (
f"Nohardlink Error: Unable to open the folder {file}. "
"Please make sure qbit_manage has access to this directory."
"Please make sure folder exists and qbit_manage has access to this directory."
)
raise Failed(msg)
notify(msg, "nohardlink")
logger.warning(msg)
largest_file_size = os.stat(sorted_files[0]).st_size
logger.trace(f"Largest file: {sorted_files[0]}")
logger.trace(f"Largest file size: {largest_file_size}")