Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor SUSE repo cleanup and local path generation logic supporting Akamai CDN #1257

Merged
merged 6 commits into from
Dec 16, 2024
6 changes: 4 additions & 2 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ class Repository < ApplicationRecord
class << self

def remove_suse_repos_without_tokens!
where(auth_token: nil).where('external_url LIKE ?', 'https://updates.suse.com%').delete_all
where(auth_token: nil)
.where("external_url LIKE 'https://updates.suse.com%' OR external_url LIKE 'https://dl.suse.com%'")
.delete_all
digitaltom marked this conversation as resolved.
Show resolved Hide resolved
end

# Mangles remote repo URL to make a nicer local path, see specs for examples
def make_local_path(url)
uri = URI(url)
path = uri.path.to_s
path.gsub!(%r{^/repo}, '') if (uri.hostname == 'updates.suse.com')
path.gsub!(%r{^/repo}, '') if (uri.hostname == 'updates.suse.com' || uri.hostname == 'dl.suse.com')
digitaltom marked this conversation as resolved.
Show resolved Hide resolved
(path == '') ? '/' : path
end

Expand Down
Loading