Skip to content

Commit

Permalink
Add safety check to repair
Browse files Browse the repository at this point in the history
  • Loading branch information
westsurname authored Nov 11, 2024
1 parent f0b93e2 commit aeea5c0
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import argparse
import time
import traceback
import shared.debrid # Run validation
from shared.debrid import validateRealdebridMountTorrentsPath, validateTorboxMountTorrentsPath
from shared.arr import Sonarr, Radarr
from shared.discord import discordUpdate, discordError
from shared.shared import repair, realdebrid, torbox, intersperse
from shared.shared import repair, realdebrid, torbox, intersperse, ensureTuple
from datetime import datetime

def parseInterval(intervalStr):
Expand Down Expand Up @@ -55,6 +55,11 @@ def print(*values: object):
exit(1)

def main():
if unsafe():
print("One or both debrid services are not working properly. Skipping repair.")
discordError(f"[{args.mode}] One or both debrid services are not working properly. Skipping repair.")
return

print("Collecting media...")
sonarr = Sonarr()
radarr = Radarr()
Expand All @@ -64,6 +69,11 @@ def main():

for arr, media in intersperse(sonarrMedia, radarrMedia):
try:
if unsafe():
print("One or both debrid services are not working properly. Skipping repair.")
discordError(f"[{args.mode}] One or both debrid services are not working properly. Skipping repair.")
return

getItems = lambda media, childId: arr.getFiles(media=media, childId=childId) if args.mode == 'symlink' else arr.getHistory(media=media, childId=childId, includeGrandchildDetails=True)
childrenIds = media.childrenIds if args.include_unmonitored else media.monitoredChildrenIds

Expand Down Expand Up @@ -129,6 +139,11 @@ def main():
print("Repair complete")
discordUpdate(f"[{args.mode}] Repair complete")

def unsafe():
return (args.mode == 'symlink' and
((realdebrid['enabled'] and not ensureTuple(validateRealdebridMountTorrentsPath())[0]) or
(torbox['enabled'] and not ensureTuple(validateTorboxMountTorrentsPath())[0])))

if runIntervalSeconds > 0:
while True:
try:
Expand Down

0 comments on commit aeea5c0

Please sign in to comment.