From ac1e902d5916323703c62a77bd4d508066f46131 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Tue, 11 Sep 2012 16:42:07 -0700 Subject: [PATCH] Allow an incoming identifier to be specified for a JsonStore. --- .../Framework/Interfaces/IJsonStoreModule.cs | 2 +- .../Scripting/JsonStore/JsonStoreModule.cs | 14 +++++++------- .../Scripting/JsonStore/JsonStoreScriptModule.cs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs index baac6e827f..da39e95638 100644 --- a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces public interface IJsonStoreModule { - bool CreateStore(string value, out UUID result); + bool CreateStore(string value, ref UUID result); bool DestroyStore(UUID storeID); bool TestPath(UUID storeID, string path, bool useJson); bool SetValue(UUID storeID, string path, string value, bool useJson); diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs index 311531c8d4..732c28f66d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs @@ -175,14 +175,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// /// // ----------------------------------------------------------------- - public bool CreateStore(string value, out UUID result) + public bool CreateStore(string value, ref UUID result) { - result = UUID.Zero; + if (result == UUID.Zero) + result = UUID.Random(); + + JsonStore map = null; if (! m_enabled) return false; - UUID uuid = UUID.Random(); - JsonStore map = null; try { @@ -195,9 +196,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore } lock (m_JsonValueStore) - m_JsonValueStore.Add(uuid,map); + m_JsonValueStore.Add(result,map); - result = uuid; return true; } @@ -231,7 +231,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore if (! m_JsonValueStore.TryGetValue(storeID,out map)) { m_log.InfoFormat("[JsonStore] Missing store {0}",storeID); - return true; + return false; } } diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index eaba816179..6910d14c67 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs @@ -227,7 +227,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore protected UUID JsonCreateStore(UUID hostID, UUID scriptID, string value) { UUID uuid = UUID.Zero; - if (! m_store.CreateStore(value, out uuid)) + if (! m_store.CreateStore(value, ref uuid)) GenerateRuntimeError("Failed to create Json store"); return uuid;