mirror of
				https://github.com/velopack/velopack.git
				synced 2025-10-25 15:19:22 +00:00 
			
		
		
		
	Same deal with deltas
This commit is contained in:
		| @@ -68,17 +68,11 @@ namespace Squirrel | |||||||
|                 this.Log().Info("Extracting {0} and {1} into {2}",  |                 this.Log().Info("Extracting {0} and {1} into {2}",  | ||||||
|                     basePackage.ReleasePackageFile, newPackage.ReleasePackageFile, tempPath); |                     basePackage.ReleasePackageFile, newPackage.ReleasePackageFile, tempPath); | ||||||
| 
 | 
 | ||||||
|  |                 Utility.ExtractZipToDirectory(basePackage.ReleasePackageFile, baseTempInfo.FullName).Wait(); | ||||||
|                 var opts = new ExtractionOptions() { ExtractFullPath = true, Overwrite = true, PreserveFileTime = true }; |                 var opts = new ExtractionOptions() { ExtractFullPath = true, Overwrite = true, PreserveFileTime = true }; | ||||||
| 
 | 
 | ||||||
|                 using (var za = ZipArchive.Open(basePackage.ReleasePackageFile)) |                 Utility.ExtractZipToDirectory(basePackage.ReleasePackageFile, baseTempInfo.FullName).Wait(); | ||||||
|                 using (var reader = za.ExtractAllEntries()) { |                 Utility.ExtractZipToDirectory(newPackage.ReleasePackageFile, tempInfo.FullName).Wait(); | ||||||
|                     reader.WriteAllToDirectory(baseTempInfo.FullName, opts); |  | ||||||
|                 } |  | ||||||
| 
 |  | ||||||
|                 using (var za = ZipArchive.Open(basePackage.ReleasePackageFile)) |  | ||||||
|                 using (var reader = za.ExtractAllEntries()) { |  | ||||||
|                     reader.WriteAllToDirectory(tempInfo.FullName, opts); |  | ||||||
|                 } |  | ||||||
| 
 | 
 | ||||||
|                 // Collect a list of relative paths under 'lib' and map them |                 // Collect a list of relative paths under 'lib' and map them | ||||||
|                 // to their full name. We'll use this later to determine in |                 // to their full name. We'll use this later to determine in | ||||||
| @@ -95,10 +89,7 @@ namespace Squirrel | |||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 ReleasePackage.addDeltaFilesToContentTypes(tempInfo.FullName); |                 ReleasePackage.addDeltaFilesToContentTypes(tempInfo.FullName); | ||||||
|                 using (var za = ZipArchive.Create()) { |                 Utility.CreateZipFromDirectory(outputFile, tempInfo.FullName).Wait(); | ||||||
|                     za.AddAllFromDirectory(tempInfo.FullName); |  | ||||||
|                     za.SaveTo(outputFile, CompressionType.Deflate); |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             return new ReleasePackage(outputFile); |             return new ReleasePackage(outputFile); | ||||||
|   | |||||||
| @@ -163,7 +163,7 @@ namespace Squirrel | |||||||
| 
 | 
 | ||||||
|                 contentsPostProcessHook?.Invoke(tempPath); |                 contentsPostProcessHook?.Invoke(tempPath); | ||||||
| 
 | 
 | ||||||
|                 createZipEncoded(outputFile, tempPath); |                 Utility.CreateZipFromDirectory(outputFile, tempPath).Wait(); | ||||||
| 
 | 
 | ||||||
|                 ReleasePackageFile = outputFile; |                 ReleasePackageFile = outputFile; | ||||||
|                 return ReleasePackageFile; |                 return ReleasePackageFile; | ||||||
| @@ -217,28 +217,6 @@ namespace Squirrel | |||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Create zip file with entry names %-encoded, as nupkg file does. |  | ||||||
|         void createZipEncoded(string zipFilePath, string folder) |  | ||||||
|         { |  | ||||||
|             var sevenZip = Path.Combine( |  | ||||||
|                 Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), |  | ||||||
|                 "7z.exe"); |  | ||||||
| 
 |  | ||||||
|             Utility.InvokeProcessAsync(sevenZip, String.Format("a \"{0}\" -tzip -mmt on *", zipFilePath), CancellationToken.None, folder) |  | ||||||
|                 .Wait(); |  | ||||||
| 
 |  | ||||||
|             /* |  | ||||||
|             using (var archive = ZipArchive.Create()) |  | ||||||
|             using (var tgt = File.OpenWrite(zipFilePath)) { |  | ||||||
|                 archive.DeflateCompressionLevel = CompressionLevel.BestCompression; |  | ||||||
|                 archive.AddAllFromDirectory(folder); |  | ||||||
|                 archive.SaveTo( |  | ||||||
|                     tgt, |  | ||||||
|                     new WriterOptions(CompressionType.Deflate)); |  | ||||||
|             } |  | ||||||
|             */ |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         void extractDependentPackages(IEnumerable<IPackage> dependencies, DirectoryInfo tempPath, FrameworkName framework) |         void extractDependentPackages(IEnumerable<IPackage> dependencies, DirectoryInfo tempPath, FrameworkName framework) | ||||||
|         { |         { | ||||||
|             dependencies.ForEach(pkg => { |             dependencies.ForEach(pkg => { | ||||||
|   | |||||||
| @@ -386,6 +386,20 @@ namespace Squirrel | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         public static async Task CreateZipFromDirectory(string zipFilePath, string inFolder) | ||||||
|  |         { | ||||||
|  |             var sevenZip = Utility.FindHelperExecutable("7z.exe"); | ||||||
|  |             var result = default(Tuple<int, string>); | ||||||
|  | 
 | ||||||
|  |             try { | ||||||
|  |                 result = await Utility.InvokeProcessAsync(sevenZip, String.Format("a \"{0}\" -tzip -mmt on *", zipFilePath), CancellationToken.None, inFolder); | ||||||
|  |                 if (result.Item1 != 0) throw new Exception(result.Item2); | ||||||
|  |             } catch (Exception ex) { | ||||||
|  |                 Log().Error($"Failed to extract file {zipFilePath} to {inFolder}\n{ex.Message}"); | ||||||
|  |                 throw; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         public static string AppDirForRelease(string rootAppDirectory, ReleaseEntry entry) |         public static string AppDirForRelease(string rootAppDirectory, ReleaseEntry entry) | ||||||
|         { |         { | ||||||
|             return Path.Combine(rootAppDirectory, "app-" + entry.Version.ToString()); |             return Path.Combine(rootAppDirectory, "app-" + entry.Version.ToString()); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user