private string CreatePackage(PackageType packageType, Archive archive, ArchiveMetadata metadata, string outputDirectory) { EnsureSufficientDiskSpace(archive, outputDirectory); string packageDirectory = CreatePackageDirectory(archive, outputDirectory); string packageFilePath = Path.Combine(packageDirectory, archive.GetInformationPackageFileName()); Stream outStream = File.Create(packageFilePath); TarArchive tarArchive = TarArchive.CreateOutputTarArchive(new TarOutputStream(outStream)); string packageRootDirectory = archive.Uuid.GetValue() + Path.DirectorySeparatorChar; CreateEntry(packageRootDirectory, false, new DirectoryInfo("none"), tarArchive, string.Empty, string.Empty); AddFilesInDirectory( archive, archive.WorkingDirectory.Root().DirectoryInfo(), packageType, tarArchive, packageRootDirectory ); if (archive.WorkingDirectory.HasExternalContentDirectory()) { Log.Debug($"Archive has external content directory, including files from {archive.WorkingDirectory.Content()}"); string contentDirectory = packageRootDirectory + ArkadeConstants.DirectoryNameContent + Path.DirectorySeparatorChar; AddFilesInDirectory( archive, archive.WorkingDirectory.Content().DirectoryInfo(), null, tarArchive, contentDirectory ); } tarArchive.Close(); new InfoXmlCreator().CreateAndSaveFile(metadata, packageFilePath, archive.GetInfoXmlFileName()); HasRun = true; return(packageFilePath); }
/// <summary> /// Create AIP (Archival Information Package) /// Package- and metafile are written to the given output directory /// The full path of the created package is returned /// </summary> public string CreateAip(Archive archive, ArchiveMetadata metadata, string outputDirectory) { string packageFilePath = CreatePackage(PackageType.ArchivalInformationPackage, archive, metadata, outputDirectory); return(packageFilePath); }