Skip to content

Commit

Permalink
Fix bug with old resources not being removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Nullreff committed Jan 24, 2014
1 parent e3e5eac commit 95f2526
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/bukin/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def install_resources(resources)
installer = Installer.new(Dir.pwd, true)
state = State.new(Dir.pwd)

# Install new resources
resources.each do |resource|
if state.files.installed?(resource.name, resource.version)
using_section(resource.name, resource.version)
Expand All @@ -120,6 +121,12 @@ def install_resources(resources)
end
end
end

# Remove old resources
names = resources.map(&:name)
state.files.names.each do |name|
state.files.delete(name) unless names.include?(name)
end
end

PROVIDERS = {
Expand Down
8 changes: 7 additions & 1 deletion lib/bukin/state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ def installed?(name, version)
def delete(name)
(self[name] || {}).each do |version, files|
files.each do |file|
FileUtils.rm_r(file)
FileUtils.rm_r(file) if File.exist?(file)
end
end

@files.delete(name)
end

def names
@files.keys
end

def save
Expand Down
1 change: 1 addition & 0 deletions spec/state_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@
state.files.delete('worldguard')

File.exist?('plugins/WorldGuard.jar').should be_false
state.files['worldguard', '1.0.0'].should be_nil
end
end

0 comments on commit 95f2526

Please sign in to comment.