Ejemplo n.º 1
0
        /// <summary>
        /// Used in the deployment chain to pack each bundled temporary folder to an archive.
        /// </summary>
        private static void PackBundledArchives(ResourceList resources, DeployArchiveList archives, bool freezeArchives)
        {
            // For each archive...
            foreach (DeployArchive archive in archives.Reverse())
            {
                // ... if needed ...
                if (archive.Count > 0 && !Utils.IsDirectoryEmpty(archive.TempPath))
                {
                    // ... pack the temporary folder to an archive ...
                    if (freezeArchives)
                    {
                        LogFile.WriteLine($"      Freezing archive '{archive.ArchiveName}'");

                        // either freeze to FrozenData and then copy to Data:
                        Archive2.Create(archive.GetFrozenArchivePath(), archive.TempPath, archive.Compression, archive.Format);

                        if (Configuration.bUseHardlinks)
                        {
                            Utils.CreateHardLink(archive.GetFrozenArchivePath(), archive.GetArchivePath(), true);
                        }
                        else
                        {
                            File.Copy(archive.GetFrozenArchivePath(), archive.GetArchivePath(), true);
                        }
                    }
                    else
                    {
                        LogFile.WriteLine($"      Creating archive '{archive.ArchiveName}'");

                        // or create directly in Data:
                        Archive2.Create(archive.GetArchivePath(), archive.TempPath, archive.Compression, archive.Format);
                    }

                    // ... and add it to the resource list.
                    resources.Insert(0, archive.ArchiveName);
                }
            }

            // Clean up after we're finished.
            LogFile.WriteLine($"      Deleting temporary folder...");
            archives.DeleteTempFolder();
        }