Class: Capistrano::NetStorage::Cleaner
- Inherits:
-
Object
- Object
- Capistrano::NetStorage::Cleaner
- Includes:
- Utils
- Defined in:
- lib/capistrano/net_storage/cleaner.rb
Overview
Executor class for cleaning tasks
Instance Method Summary collapse
-
#cleanup_local_release ⇒ Object
Clean up local release directories and archives.
Instance Method Details
#cleanup_local_release ⇒ Object
Clean up local release directories and archives. Assumes they are under config.local_releases_path
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/capistrano/net_storage/cleaner.rb', line 12 def cleanup_local_release c = config run_locally do releases = capture(:ls, '-xtr', c.local_releases_path).split # Contains archive files and extracted directories if releases.count > fetch(:keep_releases) * 2 info "Keeping #{fetch(:keep_releases)} * 2 of #{releases.count} local releases" olds_str = (releases - releases.last(fetch(:keep_releases) * 2)).map do |file| c.local_releases_path.join(file) end.join(' ') execute :rm, '-rf', olds_str else info "No old local releases in #{c.local_releases_path}" end end end |