diff options
author | Christopher Baines <mail@cbaines.net> | 2018-12-31 18:22:12 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-01-01 02:38:23 +0000 |
commit | 3459059ed1f9332a9e71a4a7be5dc5e22e7f6bae (patch) | |
tree | 477f63fbc4546ee2947f571b831fb9463e2025b2 /app/jobs | |
parent | 3e78356904b610aa149dd2e2c30e832408f37acc (diff) | |
download | govuk-mini-environment-admin-3459059ed1f9332a9e71a4a7be5dc5e22e7f6bae.tar govuk-mini-environment-admin-3459059ed1f9332a9e71a4a7be5dc5e22e7f6bae.tar.gz |
Start tracking which store paths are in use
This will enable garbage collection of the Guix store, without
removing things that are still in use.
Diffstat (limited to 'app/jobs')
-rw-r--r-- | app/jobs/govuk_guix/create_data_snapshot_job.rb | 2 | ||||
-rw-r--r-- | app/jobs/govuk_guix/fetch_revision_job.rb | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/app/jobs/govuk_guix/create_data_snapshot_job.rb b/app/jobs/govuk_guix/create_data_snapshot_job.rb index 88a5ba4..bcc8aa1 100644 --- a/app/jobs/govuk_guix/create_data_snapshot_job.rb +++ b/app/jobs/govuk_guix/create_data_snapshot_job.rb @@ -87,6 +87,8 @@ class GovukGuix::CreateDataSnapshotJob < Que::Job from_remote_host: remote_host ) + backend.add_in_use_store_path(build_output) + GovukGuix::DataSnapshot.transaction do GovukGuix::DataSnapshot.create!(data_snapshot_fields) diff --git a/app/jobs/govuk_guix/fetch_revision_job.rb b/app/jobs/govuk_guix/fetch_revision_job.rb index fd6e09c..7b1acdf 100644 --- a/app/jobs/govuk_guix/fetch_revision_job.rb +++ b/app/jobs/govuk_guix/fetch_revision_job.rb @@ -27,9 +27,11 @@ class GovukGuix::FetchRevisionJob < Que::Job def run(commit_hash, options = {}) backend_type_and_id = options[:backend_type_and_id] if backend_type_and_id - remote_host = Backends.find_by_type_and_id( + backend = Backends.find_by_type_and_id( *backend_type_and_id.split('=') - ).build_remote_host + ) + + remote_host = backend.build_remote_host end sha = fetch_and_checkout(commit_hash, remote_host) @@ -51,6 +53,8 @@ class GovukGuix::FetchRevisionJob < Que::Job store_path = output.last.strip logger.debug(self.class) { "store_path: #{store_path}" } + backend.add_in_use_store_path(store_path) if backend + GovukGuix::Revision.transaction do GovukGuix::Revision.create( commit_hash: sha, |