InventoryArchiveWriteRequest.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.IO;
  30. using System.IO.Compression;
  31. using System.Reflection;
  32. using System.Xml;
  33. using log4net;
  34. using OpenMetaverse;
  35. using OpenSim.Framework;
  36. using OpenSim.Framework.Monitoring;
  37. using OpenSim.Framework.Serialization;
  38. using OpenSim.Framework.Serialization.External;
  39. using OpenSim.Region.CoreModules.World.Archiver;
  40. using OpenSim.Region.Framework.Scenes;
  41. using OpenSim.Services.Interfaces;
  42. using Ionic.Zlib;
  43. using GZipStream = Ionic.Zlib.GZipStream;
  44. using CompressionMode = Ionic.Zlib.CompressionMode;
  45. using CompressionLevel = Ionic.Zlib.CompressionLevel;
  46. using PermissionMask = OpenSim.Framework.PermissionMask;
  47. namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
  48. {
  49. public class InventoryArchiveWriteRequest
  50. {
  51. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  52. /// <summary>
  53. /// Determine whether this archive will save assets. Default is true.
  54. /// </summary>
  55. public bool SaveAssets { get; set; }
  56. /// <summary>
  57. /// Determines which items will be included in the archive, according to their permissions.
  58. /// Default is null, meaning no permission checks.
  59. /// </summary>
  60. public string FilterContent { get; set; }
  61. /// <summary>
  62. /// Counter for inventory items saved to archive for passing to compltion event
  63. /// </summary>
  64. public int CountItems { get; set; }
  65. /// <summary>
  66. /// Counter for inventory items skipped due to permission filter option for passing to compltion event
  67. /// </summary>
  68. public int CountFiltered { get; set; }
  69. /// <value>
  70. /// Used to select all inventory nodes in a folder but not the folder itself
  71. /// </value>
  72. private const string STAR_WILDCARD = "*";
  73. private InventoryArchiverModule m_module;
  74. private UserAccount m_userInfo;
  75. private string m_invPath;
  76. protected TarArchiveWriter m_archiveWriter;
  77. protected UuidGatherer m_assetGatherer;
  78. /// <value>
  79. /// We only use this to request modules
  80. /// </value>
  81. protected Scene m_scene;
  82. /// <value>
  83. /// ID of this request
  84. /// </value>
  85. protected UUID m_id;
  86. /// <value>
  87. /// Used to collect the uuids of the users that we need to save into the archive
  88. /// </value>
  89. protected Dictionary<UUID, int> m_userUuids = new Dictionary<UUID, int>();
  90. /// <value>
  91. /// The stream to which the inventory archive will be saved.
  92. /// </value>
  93. private Stream m_saveStream;
  94. /// <summary>
  95. /// Constructor
  96. /// </summary>
  97. public InventoryArchiveWriteRequest(
  98. UUID id, InventoryArchiverModule module, Scene scene,
  99. UserAccount userInfo, string invPath, string savePath)
  100. : this(
  101. id,
  102. module,
  103. scene,
  104. userInfo,
  105. invPath,
  106. new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress, CompressionLevel.BestCompression))
  107. {
  108. }
  109. /// <summary>
  110. /// Constructor
  111. /// </summary>
  112. public InventoryArchiveWriteRequest(
  113. UUID id, InventoryArchiverModule module, Scene scene,
  114. UserAccount userInfo, string invPath, Stream saveStream)
  115. {
  116. m_id = id;
  117. m_module = module;
  118. m_scene = scene;
  119. m_userInfo = userInfo;
  120. m_invPath = invPath;
  121. m_saveStream = saveStream;
  122. m_assetGatherer = new UuidGatherer(m_scene.AssetService);
  123. SaveAssets = true;
  124. FilterContent = null;
  125. }
  126. protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids, bool timedOut)
  127. {
  128. Exception reportedException = null;
  129. bool succeeded = true;
  130. try
  131. {
  132. m_archiveWriter.Close();
  133. }
  134. catch (Exception e)
  135. {
  136. reportedException = e;
  137. succeeded = false;
  138. }
  139. finally
  140. {
  141. m_saveStream.Close();
  142. }
  143. if (timedOut)
  144. {
  145. succeeded = false;
  146. reportedException = new Exception("Loading assets timed out");
  147. }
  148. m_module.TriggerInventoryArchiveSaved(
  149. m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException, CountItems, CountFiltered);
  150. }
  151. protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService)
  152. {
  153. if (options.ContainsKey("exclude"))
  154. {
  155. if (((List<String>)options["exclude"]).Contains(inventoryItem.Name) ||
  156. ((List<String>)options["exclude"]).Contains(inventoryItem.ID.ToString()))
  157. {
  158. if (options.ContainsKey("verbose"))
  159. {
  160. m_log.InfoFormat(
  161. "[INVENTORY ARCHIVER]: Skipping inventory item {0} {1} at {2}",
  162. inventoryItem.Name, inventoryItem.ID, path);
  163. }
  164. CountFiltered++;
  165. return;
  166. }
  167. }
  168. // Check For Permissions Filter Flags
  169. if (!CanUserArchiveObject(m_userInfo.PrincipalID, inventoryItem))
  170. {
  171. m_log.InfoFormat(
  172. "[INVENTORY ARCHIVER]: Insufficient permissions, skipping inventory item {0} {1} at {2}",
  173. inventoryItem.Name, inventoryItem.ID, path);
  174. // Count Items Excluded
  175. CountFiltered++;
  176. return;
  177. }
  178. if (options.ContainsKey("verbose"))
  179. m_log.InfoFormat(
  180. "[INVENTORY ARCHIVER]: Saving item {0} {1} (asset UUID {2})",
  181. inventoryItem.ID, inventoryItem.Name, inventoryItem.AssetID);
  182. string filename = path + CreateArchiveItemName(inventoryItem);
  183. // Record the creator of this item for user record purposes (which might go away soon)
  184. m_userUuids[inventoryItem.CreatorIdAsUuid] = 1;
  185. string serialization = UserInventoryItemSerializer.Serialize(inventoryItem, options, userAccountService);
  186. m_archiveWriter.WriteFile(filename, serialization);
  187. AssetType itemAssetType = (AssetType)inventoryItem.AssetType;
  188. // Count inventory items (different to asset count)
  189. CountItems++;
  190. // Don't chase down link asset items as they actually point to their target item IDs rather than an asset
  191. if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder)
  192. {
  193. int curErrorCntr = m_assetGatherer.ErrorCount;
  194. int possible = m_assetGatherer.possibleNotAssetCount;
  195. m_assetGatherer.AddForInspection(inventoryItem.AssetID);
  196. m_assetGatherer.GatherAll();
  197. curErrorCntr = m_assetGatherer.ErrorCount - curErrorCntr;
  198. possible = m_assetGatherer.possibleNotAssetCount - possible;
  199. if(curErrorCntr > 0 || possible > 0)
  200. {
  201. string spath;
  202. int indx = path.IndexOf("__");
  203. if(indx > 0)
  204. spath = path.Substring(0,indx);
  205. else
  206. spath = path;
  207. if(curErrorCntr > 0)
  208. {
  209. m_log.ErrorFormat("[INVENTORY ARCHIVER Warning]: item {0} '{1}', type {2}, in '{3}', contains {4} references to missing or damaged assets",
  210. inventoryItem.ID, inventoryItem.Name, itemAssetType.ToString(), spath, curErrorCntr);
  211. if(possible > 0)
  212. m_log.WarnFormat("[INVENTORY ARCHIVER Warning]: item also contains {0} references that may be to missing or damaged assets or not a problem", possible);
  213. }
  214. else if(possible > 0)
  215. {
  216. m_log.WarnFormat("[INVENTORY ARCHIVER Warning]: item {0} '{1}', type {2}, in '{3}', contains {4} references that may be to missing or damaged assets or not a problem", inventoryItem.ID, inventoryItem.Name, itemAssetType.ToString(), spath, possible);
  217. }
  218. }
  219. }
  220. }
  221. /// <summary>
  222. /// Save an inventory folder
  223. /// </summary>
  224. /// <param name="inventoryFolder">The inventory folder to save</param>
  225. /// <param name="path">The path to which the folder should be saved</param>
  226. /// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param>
  227. /// <param name="options"></param>
  228. /// <param name="userAccountService"></param>
  229. protected void SaveInvFolder(
  230. InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself,
  231. Dictionary<string, object> options, IUserAccountService userAccountService)
  232. {
  233. if (options.ContainsKey("excludefolders"))
  234. {
  235. if (((List<String>)options["excludefolders"]).Contains(inventoryFolder.Name) ||
  236. ((List<String>)options["excludefolders"]).Contains(inventoryFolder.ID.ToString()))
  237. {
  238. if (options.ContainsKey("verbose"))
  239. {
  240. m_log.InfoFormat(
  241. "[INVENTORY ARCHIVER]: Skipping folder {0} at {1}",
  242. inventoryFolder.Name, path);
  243. }
  244. return;
  245. }
  246. }
  247. if (options.ContainsKey("verbose"))
  248. m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving folder {0}", inventoryFolder.Name);
  249. if (saveThisFolderItself)
  250. {
  251. path += CreateArchiveFolderName(inventoryFolder);
  252. // We need to make sure that we record empty folders
  253. m_archiveWriter.WriteDir(path);
  254. }
  255. InventoryCollection contents
  256. = m_scene.InventoryService.GetFolderContent(inventoryFolder.Owner, inventoryFolder.ID);
  257. foreach (InventoryFolderBase childFolder in contents.Folders)
  258. {
  259. SaveInvFolder(childFolder, path, true, options, userAccountService);
  260. }
  261. foreach (InventoryItemBase item in contents.Items)
  262. {
  263. SaveInvItem(item, path, options, userAccountService);
  264. }
  265. }
  266. /// <summary>
  267. /// Checks whether the user has permission to export an inventory item to an IAR.
  268. /// </summary>
  269. /// <param name="UserID">The user</param>
  270. /// <param name="InvItem">The inventory item</param>
  271. /// <returns>Whether the user is allowed to export the object to an IAR</returns>
  272. private bool CanUserArchiveObject(UUID UserID, InventoryItemBase InvItem)
  273. {
  274. if (FilterContent == null)
  275. return true;// Default To Allow Export
  276. bool permitted = true;
  277. bool canCopy = (InvItem.CurrentPermissions & (uint)PermissionMask.Copy) != 0;
  278. bool canTransfer = (InvItem.CurrentPermissions & (uint)PermissionMask.Transfer) != 0;
  279. bool canMod = (InvItem.CurrentPermissions & (uint)PermissionMask.Modify) != 0;
  280. if (FilterContent.Contains("C") && !canCopy)
  281. permitted = false;
  282. if (FilterContent.Contains("T") && !canTransfer)
  283. permitted = false;
  284. if (FilterContent.Contains("M") && !canMod)
  285. permitted = false;
  286. return permitted;
  287. }
  288. /// <summary>
  289. /// Execute the inventory write request
  290. /// </summary>
  291. public void Execute(Dictionary<string, object> options, IUserAccountService userAccountService)
  292. {
  293. if (options.ContainsKey("noassets") && (bool)options["noassets"])
  294. SaveAssets = false;
  295. // Set Permission filter if flag is set
  296. if (options.ContainsKey("checkPermissions"))
  297. {
  298. Object temp;
  299. if (options.TryGetValue("checkPermissions", out temp))
  300. FilterContent = temp.ToString().ToUpper();
  301. }
  302. try
  303. {
  304. InventoryFolderBase inventoryFolder = null;
  305. InventoryItemBase inventoryItem = null;
  306. InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID);
  307. bool saveFolderContentsOnly = false;
  308. // Eliminate double slashes and any leading / on the path.
  309. string[] components
  310. = m_invPath.Split(
  311. new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries);
  312. int maxComponentIndex = components.Length - 1;
  313. // If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the
  314. // folder itself. This may get more sophisicated later on
  315. if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD)
  316. {
  317. saveFolderContentsOnly = true;
  318. maxComponentIndex--;
  319. }
  320. else if (maxComponentIndex == -1)
  321. {
  322. // If the user has just specified "/", then don't save the root "My Inventory" folder. This is
  323. // more intuitive then requiring the user to specify "/*" for this.
  324. saveFolderContentsOnly = true;
  325. }
  326. m_invPath = String.Empty;
  327. for (int i = 0; i <= maxComponentIndex; i++)
  328. {
  329. m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER;
  330. }
  331. // Annoyingly Split actually returns the original string if the input string consists only of delimiters
  332. // Therefore if we still start with a / after the split, then we need the root folder
  333. if (m_invPath.Length == 0)
  334. {
  335. inventoryFolder = rootFolder;
  336. }
  337. else
  338. {
  339. m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
  340. List<InventoryFolderBase> candidateFolders
  341. = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, rootFolder, m_invPath);
  342. if (candidateFolders.Count > 0)
  343. inventoryFolder = candidateFolders[0];
  344. }
  345. // The path may point to an item instead
  346. if (inventoryFolder == null)
  347. inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath);
  348. if (null == inventoryFolder && null == inventoryItem)
  349. {
  350. // We couldn't find the path indicated
  351. string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath);
  352. Exception e = new InventoryArchiverException(errorMessage);
  353. m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e, 0, 0);
  354. if(m_saveStream != null && m_saveStream.CanWrite)
  355. m_saveStream.Close();
  356. throw e;
  357. }
  358. m_archiveWriter = new TarArchiveWriter(m_saveStream);
  359. m_log.InfoFormat("[INVENTORY ARCHIVER]: Adding control file to archive.");
  360. // Write out control file. This has to be done first so that subsequent loaders will see this file first
  361. // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
  362. // not sure how to fix this though, short of going with a completely different file format.
  363. m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile(options));
  364. if (inventoryFolder != null)
  365. {
  366. m_log.DebugFormat(
  367. "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}",
  368. inventoryFolder.Name,
  369. inventoryFolder.ID,
  370. m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath);
  371. //recurse through all dirs getting dirs and files
  372. SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService);
  373. }
  374. else if (inventoryItem != null)
  375. {
  376. m_log.DebugFormat(
  377. "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
  378. inventoryItem.Name, inventoryItem.ID, m_invPath);
  379. SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService);
  380. }
  381. // Don't put all this profile information into the archive right now.
  382. //SaveUsers();
  383. if (SaveAssets)
  384. {
  385. m_assetGatherer.GatherAll();
  386. int errors = m_assetGatherer.FailedUUIDs.Count;
  387. m_log.DebugFormat(
  388. "[INVENTORY ARCHIVER]: The items to save reference {0} possible assets", m_assetGatherer.GatheredUuids.Count + errors);
  389. if(errors > 0)
  390. m_log.DebugFormat("[INVENTORY ARCHIVER]: {0} of these have problems or are not assets and will be ignored", errors);
  391. AssetsRequest ar = new AssetsRequest(
  392. new AssetsArchiver(m_archiveWriter),
  393. m_assetGatherer.GatheredUuids, m_assetGatherer.FailedUUIDs.Count,
  394. m_scene.AssetService,
  395. m_scene.UserAccountService, m_scene.RegionInfo.ScopeID,
  396. options, ReceivedAllAssets);
  397. ar.Execute();
  398. }
  399. else
  400. {
  401. m_log.DebugFormat("[INVENTORY ARCHIVER]: Not saving assets since --noassets was specified");
  402. ReceivedAllAssets(new List<UUID>(), new List<UUID>(), false);
  403. }
  404. }
  405. catch (Exception)
  406. {
  407. m_saveStream.Close();
  408. throw;
  409. }
  410. }
  411. /// <summary>
  412. /// Save information for the users that we've collected.
  413. /// </summary>
  414. protected void SaveUsers()
  415. {
  416. m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving user information for {0} users", m_userUuids.Count);
  417. foreach (UUID creatorId in m_userUuids.Keys)
  418. {
  419. // Record the creator of this item
  420. UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, creatorId);
  421. if (creator != null)
  422. {
  423. m_archiveWriter.WriteFile(
  424. ArchiveConstants.USERS_PATH + creator.FirstName + " " + creator.LastName + ".xml",
  425. UserProfileSerializer.Serialize(creator.PrincipalID, creator.FirstName, creator.LastName));
  426. }
  427. else
  428. {
  429. m_log.WarnFormat("[INVENTORY ARCHIVER]: Failed to get creator profile for {0}", creatorId);
  430. }
  431. }
  432. }
  433. /// <summary>
  434. /// Create the archive name for a particular folder.
  435. /// </summary>
  436. ///
  437. /// These names are prepended with an inventory folder's UUID so that more than one folder can have the
  438. /// same name
  439. ///
  440. /// <param name="folder"></param>
  441. /// <returns></returns>
  442. public static string CreateArchiveFolderName(InventoryFolderBase folder)
  443. {
  444. return CreateArchiveFolderName(folder.Name, folder.ID);
  445. }
  446. /// <summary>
  447. /// Create the archive name for a particular item.
  448. /// </summary>
  449. ///
  450. /// These names are prepended with an inventory item's UUID so that more than one item can have the
  451. /// same name
  452. ///
  453. /// <param name="item"></param>
  454. /// <returns></returns>
  455. public static string CreateArchiveItemName(InventoryItemBase item)
  456. {
  457. return CreateArchiveItemName(item.Name, item.ID);
  458. }
  459. /// <summary>
  460. /// Create an archive folder name given its constituent components
  461. /// </summary>
  462. /// <param name="name"></param>
  463. /// <param name="id"></param>
  464. /// <returns></returns>
  465. public static string CreateArchiveFolderName(string name, UUID id)
  466. {
  467. return string.Format(
  468. "{0}{1}{2}/",
  469. InventoryArchiveUtils.EscapeArchivePath(name),
  470. ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
  471. id);
  472. }
  473. /// <summary>
  474. /// Create an archive item name given its constituent components
  475. /// </summary>
  476. /// <param name="name"></param>
  477. /// <param name="id"></param>
  478. /// <returns></returns>
  479. public static string CreateArchiveItemName(string name, UUID id)
  480. {
  481. return string.Format(
  482. "{0}{1}{2}.xml",
  483. InventoryArchiveUtils.EscapeArchivePath(name),
  484. ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
  485. id);
  486. }
  487. /// <summary>
  488. /// Create the control file for the archive
  489. /// </summary>
  490. /// <param name="options"></param>
  491. /// <returns></returns>
  492. public string CreateControlFile(Dictionary<string, object> options)
  493. {
  494. int majorVersion, minorVersion;
  495. if (options.ContainsKey("home"))
  496. {
  497. majorVersion = 1;
  498. minorVersion = 2;
  499. }
  500. else
  501. {
  502. majorVersion = 0;
  503. minorVersion = 3;
  504. }
  505. m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion);
  506. StringWriter sw = new StringWriter();
  507. XmlTextWriter xtw = new XmlTextWriter(sw);
  508. xtw.Formatting = Formatting.Indented;
  509. xtw.WriteStartDocument();
  510. xtw.WriteStartElement("archive");
  511. xtw.WriteAttributeString("major_version", majorVersion.ToString());
  512. xtw.WriteAttributeString("minor_version", minorVersion.ToString());
  513. xtw.WriteElementString("assets_included", SaveAssets.ToString());
  514. xtw.WriteEndElement();
  515. xtw.Flush();
  516. xtw.Close();
  517. String s = sw.ToString();
  518. sw.Close();
  519. return s;
  520. }
  521. }
  522. }