Skip to content

Commit

Permalink
[patch] Adjusted appdata folder and set all files to be cleared upon …
Browse files Browse the repository at this point in the history
…restart except for config
  • Loading branch information
Feramance committed Aug 26, 2023
1 parent 997047a commit 45e9434
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
4 changes: 2 additions & 2 deletions config.example.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This is a config file for the qBitrr Script - Make sure to change all entries of "CHANGE_ME".
# This is a config file should be moved to "C:\Users\techa\.config\qBitManager\config.toml".
# This is a config file should be moved to "C:\Users\<user>\.config\qBitManager\config.toml".


[Settings]
Expand Down Expand Up @@ -31,7 +31,7 @@ PingURLS = ["one.one.one.one", "dns.google.com"]

# FFprobe auto updates, binaries are downloaded from https://ffbinaries.com/downloads
# If this is disabled and you want ffprobe to work
# Ensure that you add the binary for your platform into ~/.config/qBitManager i.e "C:\Users\techa\.config\qBitManager\ffprobe.exe"
# Ensure that you add the binary for your platform into ~/.config/qBitManager i.e "C:\Users\<user>\.config\qBitManager\ffprobe.exe"
# If no `ffprobe` binary is found in the folder above all ffprobe functionality will be disabled.
# By default this will always be on even if config does not have these key - to disable you need to explicitly set it to `False`
FFprobeAutoUpdate = true
Expand Down
44 changes: 27 additions & 17 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -1276,19 +1276,25 @@ def _db_request_update(self, request_ids: dict[str, set[int | str]]):
condition &= tmdb_con
elif imdb_con:
condition &= imdb_con

for db_entry in (
self.model_arr_file.select()
.join(
self.model_arr_movies_file,
on=(self.model_arr_file.MovieMetadataId == self.model_arr_movies_file.Id),
join_type=JOIN.LEFT_OUTER,
)
.switch(self.model_arr_file)
.where(condition)
.order_by(self.model_arr_file.Added.desc())
):
self.db_update_single_series(db_entry=db_entry, request=True)
try:
for db_entry in (
self.model_arr_file.select()
.join(
self.model_arr_movies_file,
on=(
self.model_arr_file.MovieMetadataId
== self.model_arr_movies_file.Id
),
join_type=JOIN.LEFT_OUTER,
)
.switch(self.model_arr_file)
.where(condition)
.order_by(self.model_arr_file.Added.desc())
):
self.db_update_single_series(db_entry=db_entry, request=True)
except BaseException:
self.logger.error("Connection Error")
raise DelayLoopException(length=300, type="arr")

def db_overseerr_update(self):
if (not self.search_missing) or (not self.overseerr_requests):
Expand Down Expand Up @@ -1386,7 +1392,7 @@ def db_update(self):
):
self.db_update_single_series(db_entry=movies)
except BaseException:
self.logger.error("Connection Error")
self.logger.error("Error reading arr db file")
raise DelayLoopException(length=300, type="delay")
self.logger.trace(f"Finished updating database")

Expand Down Expand Up @@ -3009,9 +3015,13 @@ def get_queue(
pass
else:
pass
res = self.client.get_queue(
page=1, page_size=10000, sort_key="timeLeft", sort_dir="ascending"
)
try:
res = self.client.get_queue(
page=1, page_size=10000, sort_key="timeLeft", sort_dir="ascending"
)
except requests.exceptions.ConnectionError:
self.logger.error("Failed to get queue")
raise DelayLoopException(length=300, type="arr")
try:
res = res.get("records", [])
except AttributeError:
Expand Down
2 changes: 1 addition & 1 deletion qBitrr/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from qBitrr.gen_config import MyConfig, generate_doc
from qBitrr.home_path import HOME_PATH, ON_DOCKER

APPDATA_FOLDER = HOME_PATH.joinpath(".config", "qBitManager")
APPDATA_FOLDER = HOME_PATH.joinpath("qBitManager")
APPDATA_FOLDER.mkdir(parents=True, exist_ok=True)


Expand Down
4 changes: 3 additions & 1 deletion qBitrr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import atexit
import logging
import shutil
import sys
import time
from multiprocessing import freeze_support
Expand All @@ -16,7 +17,7 @@

from qBitrr.arss import ArrManager
from qBitrr.bundled_data import patched_version
from qBitrr.config import CONFIG, QBIT_DISABLED, SEARCH_ONLY, process_flags
from qBitrr.config import APPDATA_FOLDER, CONFIG, QBIT_DISABLED, SEARCH_ONLY, process_flags
from qBitrr.env_config import ENVIRO_CONFIG
from qBitrr.ffprobe import FFprobeDownloader
from qBitrr.logger import run_logs
Expand Down Expand Up @@ -194,5 +195,6 @@ def cleanup():


if __name__ == "__main__":
shutil.rmtree(APPDATA_FOLDER)
freeze_support()
run()

0 comments on commit 45e9434

Please sign in to comment.