From 51a43b30a2f0cb76de26102064551816447a675c Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Wed, 28 May 2008 16:37:43 +0000
Subject: * Put textures into a separate assets/ directory in the opensim
archive * Fix nre where the asset couldn't be found * Not ready yet
---
.../Modules/World/Archiver/ArchiveRequest.cs | 12 ++++++++-
.../Modules/World/Archiver/TarArchive.cs | 31 ++++++++++++++++++----
2 files changed, 37 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/Environment/Modules/World')
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs
index ea74941..364b31f 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs
@@ -106,10 +106,20 @@ namespace OpenSim.Region.Environment
TarArchive archive = new TarArchive();
archive.AddFile("prims.xml", m_serializedEntities);
+
+ // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar
+ //archive.AddDir("assets");
foreach (LLUUID uuid in assets.Keys)
{
- archive.AddFile(uuid.ToString() + ".jp2", assets[uuid].Data);
+ if (assets[uuid] != null)
+ {
+ archive.AddFile("assets/" + uuid.ToString() + ".jp2", assets[uuid].Data);
+ }
+ else
+ {
+ m_log.DebugFormat("[ARCHIVER]: Could not find asset {0} to archive", uuid);
+ }
}
archive.WriteTar(m_savePath);
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchive.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchive.cs
index 3a7518c..c7492fe 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchive.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchive.cs
@@ -47,6 +47,19 @@ namespace OpenSim.Region.Environment
protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
///
+ /// Add a directory to the tar archive. We can only handle one path level right now!
+ ///
+ ///
+ public void AddDir(string dirName)
+ {
+ // Directories are signalled by a final /
+ if (!dirName.EndsWith("/"))
+ dirName += "/";
+
+ AddFile(dirName, new byte[0]);
+ }
+
+ ///
/// Add a file to the tar archive
///
///
@@ -88,7 +101,7 @@ namespace OpenSim.Region.Environment
Array.Copy(nameBytes, header, nameSize);
// file mode (8)
- byte[] modeBytes = m_asciiEncoding.GetBytes("0000644");
+ byte[] modeBytes = m_asciiEncoding.GetBytes("0000755");
Array.Copy(modeBytes, 0, header, 100, 7);
// owner user id (8)
@@ -113,7 +126,14 @@ namespace OpenSim.Region.Environment
// link indicator (1)
//header[156] = m_asciiEncoding.GetBytes("0")[0];
- header[156] = 0;
+ if (filePath.EndsWith("/"))
+ {
+ header[156] = m_asciiEncoding.GetBytes("5")[0];
+ }
+ else
+ {
+ header[156] = 0;
+ }
Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 329, 7);
Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 337, 7);
@@ -142,9 +162,10 @@ namespace OpenSim.Region.Environment
// Write out data
bw.Write(data);
- int paddingRequired = 512 - (data.Length % 512);
- if (paddingRequired > 0)
+ if (data.Length % 512 != 0)
{
+ int paddingRequired = 512 - (data.Length % 512);
+
m_log.DebugFormat("Padding data with {0} bytes", paddingRequired);
byte[] padding = new byte[paddingRequired];
@@ -179,4 +200,4 @@ namespace OpenSim.Region.Environment
return oBytes;
}
}
-}
\ No newline at end of file
+}
--
cgit v1.1