aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-11-29 22:03:26 -0800
committerRob Mensching <rob@firegiant.com>2017-11-29 22:03:26 -0800
commit71c52d5af2293d3eb79882ce36b0411f81185c11 (patch)
tree23dd116bdd6abc2b0f7b488f490d1b77faa41812 /src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs
parent0fa198ed8c6c6fc81e649466879752a99fe37d08 (diff)
downloadwix-71c52d5af2293d3eb79882ce36b0411f81185c11.tar.gz
wix-71c52d5af2293d3eb79882ce36b0411f81185c11.tar.bz2
wix-71c52d5af2293d3eb79882ce36b0411f81185c11.zip
Fix source path and cabinet processing
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs60
1 files changed, 27 insertions, 33 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs
index df1ccecf..370d4b9c 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs
@@ -6,8 +6,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.IO; 7 using System.IO;
8 using System.Linq; 8 using System.Linq;
9 using WixToolset.Core.Cab;
10 using WixToolset.Core.Bind; 9 using WixToolset.Core.Bind;
10 using WixToolset.Core.Native;
11 using WixToolset.Data; 11 using WixToolset.Data;
12 using WixToolset.Extensibility; 12 using WixToolset.Extensibility;
13 13
@@ -26,7 +26,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
26 26
27 public ResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable<FileFacade> fileFacades) 27 public ResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable<FileFacade> fileFacades)
28 { 28 {
29 var filesWithPath = fileFacades.Select(f => new BindFileWithPath() { Id = f.File.File, Path = f.WixFile.Source }).ToList(); 29 var filesWithPath = fileFacades.Select(f => new BindFileWithPath() { Id = f.File.File, Path = f.WixFile.Source.Path }).ToList();
30 30
31 ResolvedCabinet resolved = null; 31 ResolvedCabinet resolved = null;
32 32
@@ -58,45 +58,39 @@ namespace WixToolset.Core.WindowsInstaller.Bind
58 // 3. modified time changed 58 // 3. modified time changed
59 bool cabinetValid = true; 59 bool cabinetValid = true;
60 60
61 // Need to force garbage collection of WixEnumerateCab to ensure the handle 61 var cabinet = new Cabinet(resolved.Path);
62 // associated with it is closed before it is reused. 62 List<CabinetFileInfo> fileList = cabinet.Enumerate();
63 using (var wixEnumerateCab = new WixEnumerateCab())
64 {
65 List<CabinetFileInfo> fileList = wixEnumerateCab.Enumerate(resolved.Path);
66 63
67 if (filesWithPath.Count() != fileList.Count) 64 if (filesWithPath.Count() != fileList.Count)
68 { 65 {
69 cabinetValid = false; 66 cabinetValid = false;
70 } 67 }
71 else 68 else
69 {
70 int i = 0;
71 foreach (BindFileWithPath file in filesWithPath)
72 { 72 {
73 int i = 0; 73 // First check that the file identifiers match because that is quick and easy.
74 foreach (BindFileWithPath file in filesWithPath) 74 CabinetFileInfo cabFileInfo = fileList[i];
75 cabinetValid = (cabFileInfo.FileId == file.Id);
76 if (cabinetValid)
75 { 77 {
76 // First check that the file identifiers match because that is quick and easy. 78 // Still valid so ensure the file sizes are the same.
77 CabinetFileInfo cabFileInfo = fileList[i]; 79 FileInfo fileInfo = new FileInfo(file.Path);
78 cabinetValid = (cabFileInfo.FileId == file.Id); 80 cabinetValid = (cabFileInfo.Size == fileInfo.Length);
79 if (cabinetValid) 81 if (cabinetValid)
80 { 82 {
81 // Still valid so ensure the file sizes are the same. 83 // Still valid so ensure the source time stamp hasn't changed.
82 FileInfo fileInfo = new FileInfo(file.Path); 84 cabinetValid = cabFileInfo.SameAsDateTime(fileInfo.LastWriteTime);
83 cabinetValid = (cabFileInfo.Size == fileInfo.Length);
84 if (cabinetValid)
85 {
86 // Still valid so ensure the source time stamp hasn't changed. Thus we need
87 // to convert the source file time stamp into a cabinet compatible data/time.
88 Native.CabInterop.DateTimeToCabDateAndTime(fileInfo.LastWriteTime, out var sourceCabDate, out var sourceCabTime);
89 cabinetValid = (cabFileInfo.Date == sourceCabDate && cabFileInfo.Time == sourceCabTime);
90 }
91 }
92
93 if (!cabinetValid)
94 {
95 break;
96 } 85 }
86 }
97 87
98 i++; 88 if (!cabinetValid)
89 {
90 break;
99 } 91 }
92
93 i++;
100 } 94 }
101 } 95 }
102 96