blob: e343da3fafe01a94256818df11042f18aa9d3927 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
module Hbc
module Cache
module_function
def ensure_cache_exists
return if Hbc.cache.exist?
odebug "Creating Cache at #{Hbc.cache}"
Hbc.cache.mkpath
end
def migrate_legacy_cache
return unless Hbc.legacy_cache.exist?
ohai "Migrating cached files to #{Hbc.cache}..."
Hbc.legacy_cache.children.select(&:symlink?).each do |symlink|
file = symlink.readlink
new_name = file.basename
.sub(/\-((?:(\d|#{DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$/x,
'--\1')
renamed_file = Hbc.cache.join(new_name)
if file.exist?
puts "#{file} -> #{renamed_file}"
FileUtils.mv(file, renamed_file)
end
FileUtils.rm(symlink)
end
FileUtils.remove_entry_secure(Hbc.legacy_cache)
end
end
end
|