mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 02:46:11 +02:00
Fix invalid gem list caching
This commit is contained in:
parent
a78c21312a
commit
c40628fd6d
@ -2,6 +2,8 @@ module FluentGem
|
||||
class GemError < StandardError; end
|
||||
|
||||
class << self
|
||||
LIST_CACHE_KEY = "gem_list".freeze
|
||||
|
||||
def install(*args)
|
||||
run("install", *args)
|
||||
end
|
||||
@ -11,11 +13,13 @@ module FluentGem
|
||||
end
|
||||
|
||||
def list
|
||||
output = `#{gem} list`
|
||||
unless $?.exitstatus.zero?
|
||||
raise GemError, "failed command: `#{gem} list`"
|
||||
Rails.cache.fetch(LIST_CACHE_KEY) do
|
||||
output = `#{gem} list`
|
||||
unless $?.exitstatus.zero?
|
||||
raise GemError, "failed command: `#{gem} list`"
|
||||
end
|
||||
output.lines
|
||||
end
|
||||
output.lines
|
||||
end
|
||||
|
||||
def run(*args)
|
||||
@ -26,6 +30,7 @@ module FluentGem
|
||||
unless system(*cmd)
|
||||
raise GemError, "failed command: `#{cmd.join(" ")}`"
|
||||
end
|
||||
Rails.cache.delete(LIST_CACHE_KEY)
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
@ -87,14 +87,12 @@ class Plugin
|
||||
end
|
||||
|
||||
def self.installed
|
||||
Rails.cache.fetch("installed_gems", expires_in: 3.seconds) do
|
||||
Bundler.with_clean_env do
|
||||
gems = FluentGem.list
|
||||
gems.grep(/fluent-plugin/).map do |gem|
|
||||
name, versions_str = gem.strip.split(" ")
|
||||
version = versions_str[/[^(), ]+/]
|
||||
new(gem_name: name, version: version)
|
||||
end
|
||||
Bundler.with_clean_env do
|
||||
gems = FluentGem.list
|
||||
gems.grep(/fluent-plugin/).map do |gem|
|
||||
name, versions_str = gem.strip.split(" ")
|
||||
version = versions_str[/[^(), ]+/]
|
||||
new(gem_name: name, version: version)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user