diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 146 |
1 files changed, 110 insertions, 36 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 55d7997..2340fad 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -51,13 +51,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
51 | public string Name { get { return "Inventory Archiver Module"; } } | 51 | public string Name { get { return "Inventory Archiver Module"; } } |
52 | 52 | ||
53 | public bool IsSharedModule { get { return true; } } | 53 | public bool IsSharedModule { get { return true; } } |
54 | |||
55 | /// <value> | ||
56 | /// Enable or disable checking whether the iar user is actually logged in | ||
57 | /// </value> | ||
58 | public bool DisablePresenceChecks { get; set; } | ||
54 | 59 | ||
55 | public event InventoryArchiveSaved OnInventoryArchiveSaved; | 60 | public event InventoryArchiveSaved OnInventoryArchiveSaved; |
56 | 61 | ||
57 | /// <summary> | 62 | /// <summary> |
58 | /// The file to load and save inventory if no filename has been specified | 63 | /// The file to load and save inventory if no filename has been specified |
59 | /// </summary> | 64 | /// </summary> |
60 | protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory_iar.tar.gz"; | 65 | protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory.iar"; |
61 | 66 | ||
62 | /// <value> | 67 | /// <value> |
63 | /// Pending save completions initiated from the console | 68 | /// Pending save completions initiated from the console |
@@ -69,19 +74,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
69 | /// </value> | 74 | /// </value> |
70 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | 75 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); |
71 | private Scene m_aScene; | 76 | private Scene m_aScene; |
72 | 77 | ||
73 | /// <value> | 78 | public InventoryArchiverModule() {} |
74 | /// The comms manager we will use for all comms requests | 79 | |
75 | /// </value> | 80 | public InventoryArchiverModule(bool disablePresenceChecks) |
76 | protected internal CommunicationsManager CommsManager; | 81 | { |
77 | protected internal IAssetService AssetService; | 82 | DisablePresenceChecks = disablePresenceChecks; |
83 | } | ||
78 | 84 | ||
79 | public void Initialise(Scene scene, IConfigSource source) | 85 | public void Initialise(Scene scene, IConfigSource source) |
80 | { | 86 | { |
81 | if (m_scenes.Count == 0) | 87 | if (m_scenes.Count == 0) |
82 | { | 88 | { |
83 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); | 89 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); |
84 | CommsManager = scene.CommsManager; | ||
85 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; | 90 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; |
86 | 91 | ||
87 | scene.AddCommand( | 92 | scene.AddCommand( |
@@ -99,11 +104,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
99 | 104 | ||
100 | m_scenes[scene.RegionInfo.RegionID] = scene; | 105 | m_scenes[scene.RegionInfo.RegionID] = scene; |
101 | } | 106 | } |
102 | 107 | ||
103 | public void PostInitialise() | 108 | public void PostInitialise() {} |
104 | { | ||
105 | AssetService = m_aScene.AssetService; | ||
106 | } | ||
107 | 109 | ||
108 | public void Close() {} | 110 | public void Close() {} |
109 | 111 | ||
@@ -119,29 +121,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
119 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); | 121 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); |
120 | } | 122 | } |
121 | 123 | ||
122 | public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream) | 124 | public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream) |
123 | { | 125 | { |
124 | if (m_scenes.Count > 0) | 126 | if (m_scenes.Count > 0) |
125 | { | 127 | { |
126 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); | 128 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); |
127 | 129 | ||
128 | if (userInfo != null) | 130 | if (userInfo != null) |
129 | new InventoryArchiveWriteRequest(id, this, userInfo, invPath, saveStream).Execute(); | 131 | { |
130 | } | 132 | if (CheckPresence(userInfo.UserProfile.ID)) |
133 | { | ||
134 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); | ||
135 | return true; | ||
136 | } | ||
137 | else | ||
138 | { | ||
139 | m_log.ErrorFormat( | ||
140 | "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", | ||
141 | userInfo.UserProfile.Name, userInfo.UserProfile.ID); | ||
142 | } | ||
143 | } | ||
144 | } | ||
145 | |||
146 | return false; | ||
131 | } | 147 | } |
132 | 148 | ||
133 | public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath) | 149 | public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath) |
134 | { | 150 | { |
135 | if (m_scenes.Count > 0) | 151 | if (m_scenes.Count > 0) |
136 | { | 152 | { |
137 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); | 153 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); |
138 | 154 | ||
139 | if (userInfo != null) | 155 | if (userInfo != null) |
140 | new InventoryArchiveWriteRequest(id, this, userInfo, invPath, savePath).Execute(); | 156 | { |
141 | } | 157 | if (CheckPresence(userInfo.UserProfile.ID)) |
158 | { | ||
159 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); | ||
160 | return true; | ||
161 | } | ||
162 | else | ||
163 | { | ||
164 | m_log.ErrorFormat( | ||
165 | "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", | ||
166 | userInfo.UserProfile.Name, userInfo.UserProfile.ID); | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | |||
171 | return false; | ||
142 | } | 172 | } |
143 | 173 | ||
144 | public void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) | 174 | public bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) |
145 | { | 175 | { |
146 | if (m_scenes.Count > 0) | 176 | if (m_scenes.Count > 0) |
147 | { | 177 | { |
@@ -149,14 +179,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
149 | 179 | ||
150 | if (userInfo != null) | 180 | if (userInfo != null) |
151 | { | 181 | { |
152 | InventoryArchiveReadRequest request = | 182 | if (CheckPresence(userInfo.UserProfile.ID)) |
153 | new InventoryArchiveReadRequest(userInfo, invPath, loadStream, CommsManager, AssetService); | 183 | { |
154 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 184 | InventoryArchiveReadRequest request = |
185 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); | ||
186 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | ||
187 | |||
188 | return true; | ||
189 | } | ||
190 | else | ||
191 | { | ||
192 | m_log.ErrorFormat( | ||
193 | "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", | ||
194 | userInfo.UserProfile.Name, userInfo.UserProfile.ID); | ||
195 | } | ||
155 | } | 196 | } |
156 | } | 197 | } |
198 | |||
199 | return false; | ||
157 | } | 200 | } |
158 | 201 | ||
159 | public void DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) | 202 | public bool DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) |
160 | { | 203 | { |
161 | if (m_scenes.Count > 0) | 204 | if (m_scenes.Count > 0) |
162 | { | 205 | { |
@@ -164,11 +207,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
164 | 207 | ||
165 | if (userInfo != null) | 208 | if (userInfo != null) |
166 | { | 209 | { |
167 | InventoryArchiveReadRequest request = | 210 | if (CheckPresence(userInfo.UserProfile.ID)) |
168 | new InventoryArchiveReadRequest(userInfo, invPath, loadPath, CommsManager, AssetService); | 211 | { |
169 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 212 | InventoryArchiveReadRequest request = |
170 | } | 213 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); |
171 | } | 214 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
215 | |||
216 | return true; | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | m_log.ErrorFormat( | ||
221 | "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", | ||
222 | userInfo.UserProfile.Name, userInfo.UserProfile.ID); | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
227 | return false; | ||
172 | } | 228 | } |
173 | 229 | ||
174 | /// <summary> | 230 | /// <summary> |
@@ -193,11 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
193 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", | 249 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", |
194 | loadPath, invPath, firstName, lastName); | 250 | loadPath, invPath, firstName, lastName); |
195 | 251 | ||
196 | DearchiveInventory(firstName, lastName, invPath, loadPath); | 252 | if (DearchiveInventory(firstName, lastName, invPath, loadPath)) |
197 | 253 | m_log.InfoFormat( | |
198 | m_log.InfoFormat( | 254 | "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", |
199 | "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", | 255 | loadPath, firstName, lastName); |
200 | loadPath, firstName, lastName); | ||
201 | } | 256 | } |
202 | 257 | ||
203 | /// <summary> | 258 | /// <summary> |
@@ -261,7 +316,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
261 | /// <returns></returns> | 316 | /// <returns></returns> |
262 | protected CachedUserInfo GetUserInfo(string firstName, string lastName) | 317 | protected CachedUserInfo GetUserInfo(string firstName, string lastName) |
263 | { | 318 | { |
264 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); | 319 | CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); |
265 | if (null == userInfo) | 320 | if (null == userInfo) |
266 | { | 321 | { |
267 | m_log.ErrorFormat( | 322 | m_log.ErrorFormat( |
@@ -301,5 +356,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
301 | } | 356 | } |
302 | } | 357 | } |
303 | } | 358 | } |
359 | |||
360 | /// <summary> | ||
361 | /// Check if the given user is present in any of the scenes. | ||
362 | /// </summary> | ||
363 | /// <param name="userId">The user to check</param> | ||
364 | /// <returns>true if the user is in any of the scenes, false otherwise</returns> | ||
365 | protected bool CheckPresence(UUID userId) | ||
366 | { | ||
367 | if (DisablePresenceChecks) | ||
368 | return true; | ||
369 | |||
370 | foreach (Scene scene in m_scenes.Values) | ||
371 | { | ||
372 | if (scene.GetScenePresence(userId) != null) | ||
373 | return true; | ||
374 | } | ||
375 | |||
376 | return false; | ||
377 | } | ||
304 | } | 378 | } |
305 | } | 379 | } |