From 69e811ef6f78e83a848f864e3987a2999f3b38ee Mon Sep 17 00:00:00 2001 From: Fabio Gallonetto Date: Thu, 21 Mar 2013 13:21:51 +0000 Subject: [PATCH] Fix a bug that's causing the installer to overwrite backup files When rake install/update is run for the second time, any .backup file created by the first run it's going to be overwritten by the new symlink even if the current file is the same as the one we are going to write. The rakefile now checks if the symlink we are going to create points to the same target as the one already there and if that's the case, doesn't overwrite any backup. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 0b3d4be..a13625e 100644 --- a/Rakefile +++ b/Rakefile @@ -169,7 +169,7 @@ def file_operation(files, method = :symlink) puts "Source: #{source}" puts "Target: #{target}" - if File.exists?(target) || File.symlink?(target) + if File.exists?(target) && (!File.symlink?(target) || (File.symlink?(target) && File.readlink(target) != source)) puts "[Overwriting] #{target}...leaving original at #{target}.backup..." run %{ mv "$HOME/.#{file}" "$HOME/.#{file}.backup" } end