diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-03-19 10:29:21 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-03-19 11:25:39 -0700 |
| commit | 13c7babf53b7c87e0147ea21732d2473477ac8cb (patch) | |
| tree | a5853338bcf559c3cb3e00467eeebdd46a490063 /src | |
| parent | eb1fe8aefa064f943f31a79ba00436947b653cdd (diff) | |
| download | wix-13c7babf53b7c87e0147ea21732d2473477ac8cb.tar.gz wix-13c7babf53b7c87e0147ea21732d2473477ac8cb.tar.bz2 wix-13c7babf53b7c87e0147ea21732d2473477ac8cb.zip | |
Minor code cleanup
Diffstat (limited to 'src')
3 files changed, 21 insertions, 28 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index f645c85e..fb5d7b83 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |||
| @@ -502,9 +502,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 502 | } | 502 | } |
| 503 | 503 | ||
| 504 | // Generate database file. | 504 | // Generate database file. |
| 505 | this.Messaging.Write(VerboseMessages.GeneratingDatabase()); | ||
| 506 | |||
| 507 | { | 505 | { |
| 506 | this.Messaging.Write(VerboseMessages.GeneratingDatabase()); | ||
| 507 | |||
| 508 | var trackMsi = this.WindowsInstallerBackendHelper.TrackFile(this.OutputPath, TrackedFileType.Final); | 508 | var trackMsi = this.WindowsInstallerBackendHelper.TrackFile(this.OutputPath, TrackedFileType.Final); |
| 509 | trackedFiles.Add(trackMsi); | 509 | trackedFiles.Add(trackMsi); |
| 510 | 510 | ||
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs index 382e6515..13b079ad 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | namespace WixToolset.Core.WindowsInstaller.Bind | 3 | namespace WixToolset.Core.WindowsInstaller.Bind |
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections; | 6 | using System.Collections.Generic; |
| 7 | using System.IO; | 7 | using System.IO; |
| 8 | using System.Linq; | 8 | using System.Linq; |
| 9 | using System.Threading; | 9 | using System.Threading; |
| @@ -17,9 +17,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 17 | /// </summary> | 17 | /// </summary> |
| 18 | internal sealed class CabinetBuilder | 18 | internal sealed class CabinetBuilder |
| 19 | { | 19 | { |
| 20 | private readonly object lockObject = new object(); | 20 | private readonly Queue<CabinetWorkItem> cabinetWorkItems; |
| 21 | |||
| 22 | private readonly Queue cabinetWorkItems; | ||
| 23 | private int threadCount; | 21 | private int threadCount; |
| 24 | 22 | ||
| 25 | // Address of Binder's callback function for Cabinet Splitting | 23 | // Address of Binder's callback function for Cabinet Splitting |
| @@ -35,10 +33,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 35 | { | 33 | { |
| 36 | if (0 >= threadCount) | 34 | if (0 >= threadCount) |
| 37 | { | 35 | { |
| 38 | throw new ArgumentOutOfRangeException("threadCount"); | 36 | throw new ArgumentOutOfRangeException(nameof(threadCount)); |
| 39 | } | 37 | } |
| 40 | 38 | ||
| 41 | this.cabinetWorkItems = new Queue(); | 39 | this.cabinetWorkItems = new Queue<CabinetWorkItem>(); |
| 42 | this.Messaging = messaging; | 40 | this.Messaging = messaging; |
| 43 | this.threadCount = threadCount; | 41 | this.threadCount = threadCount; |
| 44 | 42 | ||
| @@ -65,23 +63,20 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 65 | public void CreateQueuedCabinets() | 63 | public void CreateQueuedCabinets() |
| 66 | { | 64 | { |
| 67 | // don't create more threads than the number of cabinets to build | 65 | // don't create more threads than the number of cabinets to build |
| 68 | if (this.cabinetWorkItems.Count < this.threadCount) | 66 | var numberOfThreads = Math.Min(this.threadCount, this.cabinetWorkItems.Count); |
| 69 | { | ||
| 70 | this.threadCount = this.cabinetWorkItems.Count; | ||
| 71 | } | ||
| 72 | 67 | ||
| 73 | if (0 < this.threadCount) | 68 | if (0 < numberOfThreads) |
| 74 | { | 69 | { |
| 75 | Thread[] threads = new Thread[this.threadCount]; | 70 | var threads = new Thread[numberOfThreads]; |
| 76 | 71 | ||
| 77 | for (int i = 0; i < threads.Length; i++) | 72 | for (var i = 0; i < threads.Length; i++) |
| 78 | { | 73 | { |
| 79 | threads[i] = new Thread(new ThreadStart(this.ProcessWorkItems)); | 74 | threads[i] = new Thread(new ThreadStart(this.ProcessWorkItems)); |
| 80 | threads[i].Start(); | 75 | threads[i].Start(); |
| 81 | } | 76 | } |
| 82 | 77 | ||
| 83 | // wait for all threads to finish | 78 | // wait for all threads to finish |
| 84 | foreach (Thread thread in threads) | 79 | foreach (var thread in threads) |
| 85 | { | 80 | { |
| 86 | thread.Join(); | 81 | thread.Join(); |
| 87 | } | 82 | } |
| @@ -109,7 +104,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 109 | break; | 104 | break; |
| 110 | } | 105 | } |
| 111 | 106 | ||
| 112 | cabinetWorkItem = (CabinetWorkItem)this.cabinetWorkItems.Dequeue(); | 107 | cabinetWorkItem = this.cabinetWorkItems.Dequeue(); |
| 113 | } | 108 | } |
| 114 | 109 | ||
| 115 | // create a cabinet | 110 | // create a cabinet |
| @@ -134,7 +129,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 134 | { | 129 | { |
| 135 | this.Messaging.Write(VerboseMessages.CreateCabinet(cabinetWorkItem.CabinetFile)); | 130 | this.Messaging.Write(VerboseMessages.CreateCabinet(cabinetWorkItem.CabinetFile)); |
| 136 | 131 | ||
| 137 | int maxCabinetSize = 0; // The value of 0 corresponds to default of 2GB which means no cabinet splitting | 132 | var maxCabinetSize = 0; // The value of 0 corresponds to default of 2GB which means no cabinet splitting |
| 138 | ulong maxPreCompressedSizeInBytes = 0; | 133 | ulong maxPreCompressedSizeInBytes = 0; |
| 139 | 134 | ||
| 140 | if (this.MaximumCabinetSizeForLargeFileSplitting != 0) | 135 | if (this.MaximumCabinetSizeForLargeFileSplitting != 0) |
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs index 06fbf072..f125f497 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs | |||
| @@ -16,6 +16,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 16 | 16 | ||
| 17 | internal class GenerateDatabaseCommand | 17 | internal class GenerateDatabaseCommand |
| 18 | { | 18 | { |
| 19 | private const string IdtsSubFolder = "_idts"; | ||
| 20 | |||
| 19 | public GenerateDatabaseCommand(IMessaging messaging, IBackendHelper backendHelper, FileSystemManager fileSystemManager, WindowsInstallerData data, string outputPath, TableDefinitionCollection tableDefinitions, string intermediateFolder, int codepage, bool keepAddedColumns, bool suppressAddingValidationRows, bool useSubdirectory) | 21 | public GenerateDatabaseCommand(IMessaging messaging, IBackendHelper backendHelper, FileSystemManager fileSystemManager, WindowsInstallerData data, string outputPath, TableDefinitionCollection tableDefinitions, string intermediateFolder, int codepage, bool keepAddedColumns, bool suppressAddingValidationRows, bool useSubdirectory) |
| 20 | { | 22 | { |
| 21 | this.Messaging = messaging; | 23 | this.Messaging = messaging; |
| @@ -77,7 +79,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 77 | baseDirectory = Path.Combine(baseDirectory, filename); | 79 | baseDirectory = Path.Combine(baseDirectory, filename); |
| 78 | } | 80 | } |
| 79 | 81 | ||
| 80 | var idtFolder = Path.Combine(baseDirectory, "_idts"); | 82 | var idtFolder = Path.Combine(baseDirectory, IdtsSubFolder); |
| 81 | 83 | ||
| 82 | var type = OpenDatabase.CreateDirect; | 84 | var type = OpenDatabase.CreateDirect; |
| 83 | 85 | ||
| @@ -94,10 +96,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 94 | 96 | ||
| 95 | try | 97 | try |
| 96 | { | 98 | { |
| 97 | #if DEBUG | ||
| 98 | Console.WriteLine("Opening database at: {0}", this.OutputPath); | ||
| 99 | #endif | ||
| 100 | |||
| 101 | Directory.CreateDirectory(Path.GetDirectoryName(this.OutputPath)); | 99 | Directory.CreateDirectory(Path.GetDirectoryName(this.OutputPath)); |
| 102 | 100 | ||
| 103 | Directory.CreateDirectory(idtFolder); | 101 | Directory.CreateDirectory(idtFolder); |
| @@ -221,8 +219,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 221 | var command = new CreateIdtFileCommand(this.Messaging, importTable, this.Data.Codepage, idtDirectory, this.KeepAddedColumns); | 219 | var command = new CreateIdtFileCommand(this.Messaging, importTable, this.Data.Codepage, idtDirectory, this.KeepAddedColumns); |
| 222 | command.Execute(); | 220 | command.Execute(); |
| 223 | 221 | ||
| 224 | var buildOutput = this.BackendHelper.TrackFile(command.IdtPath, TrackedFileType.Temporary); | 222 | var trackIdt = this.BackendHelper.TrackFile(command.IdtPath, TrackedFileType.Temporary); |
| 225 | this.GeneratedTemporaryFiles.Add(buildOutput); | 223 | this.GeneratedTemporaryFiles.Add(trackIdt); |
| 226 | 224 | ||
| 227 | db.Import(command.IdtPath); | 225 | db.Import(command.IdtPath); |
| 228 | } | 226 | } |
| @@ -401,8 +399,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 401 | idtFile.WriteLine("\t_ForceCodepage"); | 399 | idtFile.WriteLine("\t_ForceCodepage"); |
| 402 | } | 400 | } |
| 403 | 401 | ||
| 404 | var trackId = this.BackendHelper.TrackFile(idtPath, TrackedFileType.Temporary); | 402 | var trackIdt = this.BackendHelper.TrackFile(idtPath, TrackedFileType.Temporary); |
| 405 | this.GeneratedTemporaryFiles.Add(trackId); | 403 | this.GeneratedTemporaryFiles.Add(trackIdt); |
| 406 | 404 | ||
| 407 | // Try to import the table into the MSI. | 405 | // Try to import the table into the MSI. |
| 408 | try | 406 | try |
| @@ -411,7 +409,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 411 | } | 409 | } |
| 412 | catch (WixInvalidIdtException) | 410 | catch (WixInvalidIdtException) |
| 413 | { | 411 | { |
| 414 | // The IDT should be valid, so an invalid code page was given. | 412 | // The IDT should always be generated correctly, so an invalid code page was given. |
| 415 | throw new WixException(ErrorMessages.IllegalCodepage(codepage)); | 413 | throw new WixException(ErrorMessages.IllegalCodepage(codepage)); |
| 416 | } | 414 | } |
| 417 | } | 415 | } |
