Installer: Delete installed files from VirtualStore (issue #21)
authorSebastian Schuberth <sschuberth@gmail.com>
Sun, 4 Nov 2012 11:18:27 +0000 (4 12:18 +0100)
committerSebastian Schuberth <sschuberth@gmail.com>
Sun, 4 Nov 2012 11:29:30 +0000 (4 12:29 +0100)
Delete files that are successfully installed from the according
VirtualStore path so that new files do not get superseded by old ones.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
share/WinGit/install.iss

index 1e4f444..fe2d5ce 100644 (file)
@@ -75,11 +75,11 @@ Name: consolefont; Description: {#COMP_CONSOLE_FONT}; Types: custom
 \r
 [Files]\r
 ; Install files that might be in use during setup under a different name.\r
-Source: git-cheetah\git_shell_ext.dll; DestDir: {app}\git-cheetah; DestName: git_shell_ext.dll.new; Flags: replacesameversion; Components: ext\cheetah\r
-Source: git-cheetah\git_shell_ext64.dll; DestDir: {app}\git-cheetah; DestName: git_shell_ext64.dll.new; Flags: replacesameversion; Components: ext\cheetah\r
+Source: git-cheetah\git_shell_ext.dll; DestDir: {app}\git-cheetah; DestName: git_shell_ext.dll.new; Flags: replacesameversion; Components: ext\cheetah; AfterInstall: DeleteFromVirtualStore\r
+Source: git-cheetah\git_shell_ext64.dll; DestDir: {app}\git-cheetah; DestName: git_shell_ext64.dll.new; Flags: replacesameversion; Components: ext\cheetah; AfterInstall: DeleteFromVirtualStore\r
 \r
-Source: *; DestDir: {app}; Excludes: \*.bmp, gpl-2.0.rtf, \*.iss, \tmp.*, \bin\*install*, \git-cheetah\git_shell_ext.dll, \git-cheetah\git_shell_ext64.dll; Flags: recursesubdirs replacesameversion sortfilesbyextension\r
-Source: ReleaseNotes.rtf; DestDir: {app}; Flags: isreadme replacesameversion\r
+Source: *; DestDir: {app}; Excludes: \*.bmp, gpl-2.0.rtf, \*.iss, \tmp.*, \bin\*install*, \git-cheetah\git_shell_ext.dll, \git-cheetah\git_shell_ext64.dll; Flags: recursesubdirs replacesameversion sortfilesbyextension; AfterInstall: DeleteFromVirtualStore\r
+Source: ReleaseNotes.rtf; DestDir: {app}; Flags: isreadme replacesameversion; AfterInstall: DeleteFromVirtualStore\r
 \r
 [Icons]\r
 Name: {group}\Git GUI; Filename: {app}\bin\wish.exe; Parameters: """{app}\libexec\git-core\git-gui"""; WorkingDir: %HOMEDRIVE%%HOMEPATH%; IconFilename: {app}\etc\git.ico\r
@@ -169,6 +169,25 @@ Type: dirifempty; Name: {app}\home
 #include "putty.inc.iss"\r
 #include "modules.inc.iss"\r
 \r
+procedure DeleteFromVirtualStore;\r
+var\r
+    VirtualStore,FileName:String;\r
+    DriveChars:Integer;\r
+begin\r
+    VirtualStore:=AddBackslash(ExpandConstant('{localappdata}'))+'VirtualStore';\r
+    FileName:=ExpandConstant(CurrentFileName);\r
+    DriveChars:=Length(ExtractFileDrive(FileName));\r
+    if DriveChars>0 then begin\r
+        Delete(FileName,1,DriveChars);\r
+        FileName:=VirtualStore+FileName;\r
+        if FileExists(FileName) and (not DeleteFile(FileName)) then begin\r
+            Log('Line {#__LINE__}: Unable delete "'+FileName+'".');\r
+            // This is not a critical error, the user can probably fix it manually,\r
+            // so we continue.\r
+        end;\r
+    end;\r
+end;\r
+\r
 function CreateHardLink(lpFileName,lpExistingFileName:String;lpSecurityAttributes:Integer):Boolean;\r
 #ifdef UNICODE\r
 external 'CreateHardLinkW@Kernel32.dll stdcall delayload setuponly';\r