diff options
| author | Paul Buetow <paul@buetow.org> | 2025-02-19 14:58:47 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-02-19 14:58:47 +0200 |
| commit | 1f085e83f018048931079e9bf0a564b461fd713c (patch) | |
| tree | 21dc2f3abe45dd34058c07f102da56fcc7eec351 /lib/dslkeywords | |
| parent | 79c1e080d47954cfd90e338685f30f1481087922 (diff) | |
fix
Diffstat (limited to 'lib/dslkeywords')
| -rw-r--r-- | lib/dslkeywords/file.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/dslkeywords/file.rb b/lib/dslkeywords/file.rb index d9a31fa..a734042 100644 --- a/lib/dslkeywords/file.rb +++ b/lib/dslkeywords/file.rb @@ -8,7 +8,7 @@ require_relative '../chained' module RCM # Backup the file on change module FileBackup - def backup!(file_path, checksum) + def backup!(file_path, checksum = Digest::SHA256.file(file_path).hexdigest) return if @without_backup backup_dir = "#{::File.dirname(file_path)}/.rcm" @@ -68,10 +68,13 @@ module RCM def evaluate_absent! if ::File.exist?(@file_path) info("Deleting #{@file_path}") - ::File.delete(@file_path) + backup!(@file_path) + ::File.delete(@file_path) if ::File.file?(@file_path) end - return unless @manage_directory + cleanup_directory! if @manage_directory + end + def cleanup_directory! parent_dir = ::File.dirname(@file_path) while Dir.empty?(parent_dir) info("Deleting empty parent directory #{parent_dir}") |
