68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/cow/application.rb', line 68
def edit_cache(_cache = CACHE_FILE)
unless @cache
load_cache
end
cache = @cache
File.open(_cache, 'w') do |file|
puts 'Updating cache file.'
if file.flock(File::LOCK_EX | File::LOCK_NB)
begin
yield cache
rescue
cache = @cache
end
if cache.class == Cow::Application::Cache
file.write(cache.to_yaml)
else
file.write(@cache.to_yaml)
end
else
raise 'File is already locked.'
end
end
load_cache(_cache)
end
|