/// <summary> /// Creates the .bloompub and bloomdigital folders /// </summary> private static CreateArtifactsExitCode CreateBloomDigitalArtifacts(string bookPath, string creator, string zippedBloomPubOutputPath, string unzippedBloomDigitalOutputPath) { #if DEBUG // Useful for allowing debugging of Bloom while running the harvester //MessageBox.Show("Attach debugger now"); #endif var exitCode = CreateArtifactsExitCode.Success; using (var tempBloomPub = TempFile.CreateAndGetPathButDontMakeTheFile()) { if (String.IsNullOrEmpty(zippedBloomPubOutputPath)) { zippedBloomPubOutputPath = tempBloomPub.Path; } BookServer bookServer = _projectContext.BookServer; var metadata = BookMetaData.FromFolder(bookPath); bool isTemplateBook = metadata.IsSuitableForMakingShells; // Build artifacts the same way from the harvester as on the user's local machine. // (similarly to a bulk publish operation) // See https://issues.bloomlibrary.org/youtrack/issue/BL-10300. var bookInfo = new BookInfo(bookPath, false); var settings = AndroidPublishSettings.GetPublishSettingsForBook(bookServer, bookInfo); using (var folderForUnzipped = new TemporaryFolder("BloomCreateArtifacts_Unzipped")) { // Ensure directory exists, just in case. Directory.CreateDirectory(Path.GetDirectoryName(zippedBloomPubOutputPath)); // Make the bloompub string unzippedPath = BloomPubMaker.CreateBloomPub( zippedBloomPubOutputPath, bookPath, bookServer, new Bloom.web.NullWebSocketProgress(), folderForUnzipped, creator, isTemplateBook, settings); // Currently the zipping process does some things we actually need, like making the cover picture // transparent (BL-7437). Eventually we plan to separate the preparation and zipping steps (BL-7445). // Until that is done, the most reliable way to get an unzipped BloomPUB for our preview is to actually // unzip the BloomPUB. if (!String.IsNullOrEmpty(unzippedBloomDigitalOutputPath)) { SIL.IO.RobustIO.DeleteDirectory(unzippedBloomDigitalOutputPath, recursive: true); // In case the folder isn't already empty // Ensure directory exists, just in case. Directory.CreateDirectory(Path.GetDirectoryName(unzippedBloomDigitalOutputPath)); ZipFile.ExtractToDirectory(zippedBloomPubOutputPath, unzippedBloomDigitalOutputPath); exitCode |= RenameBloomDigitalFiles(unzippedBloomDigitalOutputPath); } } } return(exitCode); }