Skip to content

Commit

Permalink
DB update allow multiple runs for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Jan 17, 2024
1 parent 89555d6 commit 692d3e4
Showing 1 changed file with 42 additions and 24 deletions.
66 changes: 42 additions & 24 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ def __init__(
)
self.min_free_space = FREE_SPACE
if self.min_free_space != "-1":
disk_stats = shutil.disk_usage(self.completed_folder)
self.current_free_space = disk_stats.free - parse_size(self.min_free_space)
self.current_free_space = shutil.disk_usage(self.completed_folder) - parse_size(
self.min_free_space
)
self.logger.trace("Current free space: %s", self.current_free_space)
self.apikey = CONFIG.get_or_raise(f"{name}.APIKey")
self.re_search = CONFIG.get(f"{name}.ReSearch", fallback=False)
Expand Down Expand Up @@ -1282,11 +1283,22 @@ def db_get_files_series(
condition = self.model_file.AirDateUtc.is_null(False)
if not self.search_specials:
condition &= self.model_file.SeasonNumber != 0
if not self.do_upgrade_search:
condition &= self.model_file.Searched == False
condition &= self.model_file.EpisodeFileId == 0
else:
if self.do_upgrade_search:
condition &= self.model_file.Upgrade == False
else:
if self.quality_unmet_search and not self.custom_format_unmet_search:
condition &= self.model_file.QualityMet == False
elif not self.quality_unmet_search and self.custom_format_unmet_search:
condition &= self.model_file.CustomFormatMet == False
elif self.quality_unmet_search and self.custom_format_unmet_search:
condition &= (
self.model_file.QualityMet
== False | self.model_file.CustomFormatMet
== False
)
else:
condition &= self.model_file.EpisodeFileId == 0
condition &= self.model_file.Searched == False
condition &= self.model_file.AbsoluteEpisodeNumber.is_null(
False
) | self.model_file.SceneAbsoluteEpisodeNumber.is_null(False)
Expand Down Expand Up @@ -1329,17 +1341,19 @@ def db_get_files_episodes(
if self.do_upgrade_search:
condition &= self.model_file.Upgrade == False
else:
if self.quality_unmet_search:
condition &= (
self.model_file.QualityMet == False | self.model_file.EpisodeFileId == 0
)
if self.custom_format_unmet_search:
if self.quality_unmet_search and not self.custom_format_unmet_search:
condition &= self.model_file.QualityMet == False
elif not self.quality_unmet_search and self.custom_format_unmet_search:
condition &= self.model_file.CustomFormatMet == False
elif self.quality_unmet_search and self.custom_format_unmet_search:
condition &= (
self.model_file.CustomFormatMet
== False | self.model_file.EpisodeFileId
== 0
self.model_file.QualityMet
== False | self.model_file.CustomFormatMet
== False
)
condition &= self.model_file.Searched == False
else:
condition &= self.model_file.EpisodeFileId == 0
condition &= self.model_file.Searched == False
condition &= self.model_file.AbsoluteEpisodeNumber.is_null(
False
) | self.model_file.SceneAbsoluteEpisodeNumber.is_null(False)
Expand Down Expand Up @@ -1381,15 +1395,19 @@ def db_get_files_movies(
if self.do_upgrade_search:
condition &= self.model_file.Upgrade == False
else:
if self.quality_unmet_search:
condition &= (
self.model_file.QualityMet == False | self.model_file.MovieFileId == 0
)
if self.custom_format_unmet_search:
if self.quality_unmet_search and not self.custom_format_unmet_search:
condition &= self.model_file.QualityMet == False
elif not self.quality_unmet_search and self.custom_format_unmet_search:
condition &= self.model_file.CustomFormatMet == False
elif self.quality_unmet_search and self.custom_format_unmet_search:
condition &= (
self.model_file.CustomFormatMet == False | self.model_file.MovieFileId == 0
self.model_file.QualityMet
== False | self.model_file.CustomFormatMet
== False
)
condition &= self.model_file.Searched == False
else:
condition &= self.model_file.MovieFileId == 0
condition &= self.model_file.Searched == False
for entry in (
self.model_file.select()
.where(condition)
Expand Down Expand Up @@ -1612,8 +1630,8 @@ def db_update(self):
if not self.search_missing:
return
self.db_update_todays_releases()
if self.db_update_processed and not self.search_by_year:
return
# if self.db_update_processed and not self.search_by_year:
# return
self.logger.trace(f"Started updating database")
if self.type == "sonarr":
if not self.series_search:
Expand Down

0 comments on commit 692d3e4

Please sign in to comment.