Skip to content

Commit

Permalink
Configuring new database for torrents
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Jun 26, 2024
1 parent 1fa2187 commit 1772d2f
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
PROCESS_ONLY,
QBIT_DISABLED,
RECHECK_CATEGORY,
TAGLESS,
SEARCH_LOOP_DELAY,
SEARCH_ONLY,
)
Expand Down Expand Up @@ -503,7 +504,7 @@ def __init__(
self.series_file_model: SeriesFilesModel = None
self.model_queue: EpisodeQueueModel | MovieQueueModel = None
self.persistent_queue: FilesQueued = None
self.torrent_library: TorrentLibrary = None
self.torrents: TorrentLibrary = None
self.logger.hnotice("Starting %s monitor", self._name)

@property
Expand Down Expand Up @@ -577,10 +578,10 @@ def _get_models(
]:
if self.type == "sonarr":
if self.series_search:
return EpisodeFilesModel, EpisodeQueueModel, SeriesFilesModel
return EpisodeFilesModel, EpisodeQueueModel, None
return EpisodeFilesModel, EpisodeQueueModel, SeriesFilesModel, TorrentLibrary if TAGLESS else None
return EpisodeFilesModel, EpisodeQueueModel, None, TorrentLibrary if TAGLESS else None
elif self.type == "radarr":
return MoviesFilesModel, MovieQueueModel, None
return MoviesFilesModel, MovieQueueModel, None, TorrentLibrary if TAGLESS else None
else:
raise UnhandledError(f"Well you shouldn't have reached here, Arr.type={self.type}")

Expand Down Expand Up @@ -4413,7 +4414,7 @@ def register_search_mode(self):
},
)

db1, db2, db3 = self._get_models()
db1, db2, db3, db4 = self._get_models()

class Files(db1):
class Meta:
Expand All @@ -4439,6 +4440,28 @@ class Meta:
else:
self.db.create_tables([Files, Queue, PersistingQueue])

if db4:

self.torrent_db = SqliteDatabase(None)
self.torrent_db.init(
str(self._app_data_folder.joinpath("torrents.db")),
pragmas={
"journal_mode": "wal",
"cache_size": -1 * 64000, # 64MB
"foreign_keys": 1,
"ignore_check_constraints": 0,
"synchronous": 0,
},
)

class Torrents(db4):
class Meta:
database = self.torrent_db

self.torrent_db.connect()
self.torrent_db.create_tables([Torrents])
self.torrents = Torrents

self.model_file = Files
self.model_queue = Queue
self.persistent_queue = PersistingQueue
Expand Down

0 comments on commit 1772d2f

Please sign in to comment.