/// <summary> /// If we do not have enterprise enabled, copy the book and remove all enterprise level features. /// </summary> internal static bool PrepareBookForUpload(ref Book.Book book, BookServer bookServer, string tempFolderPath, IProgress progress) { if (book.CollectionSettings.HaveEnterpriseFeatures) { return(false); } // We need to be sure that any in-memory changes have been written to disk // before we start copying/loading the new book to/from disk book.Save(); Directory.CreateDirectory(tempFolderPath); BookStorage.CopyDirectory(book.FolderPath, tempFolderPath); var bookInfo = new BookInfo(tempFolderPath, true); var copiedBook = bookServer.GetBookFromBookInfo(bookInfo); copiedBook.BringBookUpToDate(new NullProgress(), true); var pages = new List <XmlElement>(); foreach (XmlElement page in copiedBook.GetPageElements()) { pages.Add(page); } ISet <string> warningMessages = new HashSet <string>(); PublishHelper.RemoveEnterpriseFeaturesIfNeeded(copiedBook, pages, warningMessages); PublishHelper.SendBatchedWarningMessagesToProgress(warningMessages, progress); copiedBook.Save(); copiedBook.Storage.UpdateSupportFiles(); book = copiedBook; return(true); }