Skip to content

Commit

Permalink
Add option to preserve ids that are provided as arguments with --prep…
Browse files Browse the repository at this point in the history
…are-jobs (#836)

If you try to combine --prepare-jobs and running Job IDs in one command the ids got ignores since prepare_jobs overrides the set.

With this small change we use a set instead of a list we use a set and merge them later together to preserve other scheduled jobs.
  • Loading branch information
nille02 authored Feb 6, 2025
1 parent 1d24dd9 commit 30f143b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/urlwatch/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ def test_filter(self, id):
return 0

def prepare_jobs(self):
new_jobs = []
new_jobs = set()
for idx, job in enumerate(self.urlwatcher.jobs):
has_history = self.urlwatcher.cache_storage.has_history_data(job.get_guid())
if not has_history:
logger.info('Add Job: %s', job.pretty_name())
new_jobs.append(idx + 1)
if not new_jobs:
new_jobs.add(idx + 1)
if not new_jobs and not self.urlwatch_config.idx_set:
return 0
self.urlwatch_config.idx_set = frozenset(new_jobs)
self.urlwatch_config.idx_set = self.urlwatch_config.idx_set.union(new_jobs)
self.urlwatcher.run_jobs()
self.urlwatcher.close()

Expand Down

0 comments on commit 30f143b

Please sign in to comment.