From effb5784c13702e7baf342077efd2c8773b6ea54 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 19 Jun 2026 22:47:12 +0100 Subject: [PATCH] a few changes on assets store and exists return --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- OpenSim/Data/MySQL/MySQLXAssetData.cs | 2 +- OpenSim/Data/PGSQL/PGSQLAssetData.cs | 2 +- OpenSim/Data/SQLite/SQLiteAssetData.cs | 5 +++-- .../Asset/LocalAssetServiceConnector.cs | 3 +-- .../Asset/RegionAssetConnectorModule.cs | 18 ++++++++---------- .../Avatar/Appearance/AppearanceInfoModule.cs | 2 +- OpenSim/Services/AssetService/AssetService.cs | 8 +++----- OpenSim/Services/AssetService/XAssetService.cs | 5 ++--- 9 files changed, 21 insertions(+), 26 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 36a89f246e..fc1a38f6a4 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -253,7 +253,7 @@ namespace OpenSim.Data.MySQL public override bool[] AssetsExist(UUID[] uuids) { if (uuids.Length == 0) - return new bool[0]; + return []; HashSet exist = new HashSet(); diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 13c72433bb..e3b2640ab6 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -401,7 +401,7 @@ namespace OpenSim.Data.MySQL public bool[] AssetsExist(UUID[] uuids) { if (uuids.Length == 0) - return new bool[0]; + return []; HashSet exists = new HashSet(); diff --git a/OpenSim/Data/PGSQL/PGSQLAssetData.cs b/OpenSim/Data/PGSQL/PGSQLAssetData.cs index 7b79521591..a2cce87999 100644 --- a/OpenSim/Data/PGSQL/PGSQLAssetData.cs +++ b/OpenSim/Data/PGSQL/PGSQLAssetData.cs @@ -239,7 +239,7 @@ namespace OpenSim.Data.PGSQL public override bool[] AssetsExist(UUID[] uuids) { if (uuids.Length == 0) - return new bool[0]; + return []; HashSet exist = new HashSet(); diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 59d12c83d9..bf2ad6805a 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -147,7 +147,8 @@ namespace OpenSim.Data.SQLite } //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID.ToString()); - if (AssetsExist(new[] { asset.FullID })[0]) + bool[] assetsExist = AssetsExist([ asset.FullID ]); + if (assetsExist.Length > 0 && assetsExist[0]) { //LogAssetLoad(asset); @@ -218,7 +219,7 @@ namespace OpenSim.Data.SQLite public override bool[] AssetsExist(UUID[] uuids) { if (uuids.Length == 0) - return new bool[0]; + return []; HashSet exist = new HashSet(); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index b92fa63a5f..0adc522220 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs @@ -314,8 +314,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset public string Store(AssetBase asset) { - if (m_Cache != null) - m_Cache.Cache(asset); + m_Cache?.Cache(asset); if (asset.Local) { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RegionAssetConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RegionAssetConnectorModule.cs index c9856ca211..5c1a70a56c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RegionAssetConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RegionAssetConnectorModule.cs @@ -512,7 +512,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset return m_localConnector.AssetsExist(ids); else if (m_HGConnector != null) return m_HGConnector.AssetsExist(ids); - return null; + return []; } public string Store(AssetBase asset) @@ -524,12 +524,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset return null; id = StoreForeign(asset); - if (m_Cache != null) - { - if (!string.IsNullOrEmpty(id) && !id.Equals(UUID.ZeroString)) - m_Cache.Cache(asset); + if (!string.IsNullOrEmpty(id) && !id.Equals(UUID.ZeroString)) + { + m_Cache?.Cache(asset); + return id; } - return id; + else + return string.Empty; } if (m_Cache != null) @@ -541,10 +542,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset id = StoreLocal(asset); - if (string.IsNullOrEmpty(id)) - return string.Empty; - - return id; + return string.IsNullOrEmpty(id) || id.Equals(UUID.ZeroString) ? string.Empty : id; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index 68cdb3b9db..1ec0e47ea9 100755 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs @@ -451,7 +451,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance assetStrings[k], existChecks[k] ? "yes" : "no"); sb.Append(cdt.ToString()); - sb.Append("\n"); + sb.Append('\n'); } } else diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index e648df6574..a3a9d9cab2 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -168,15 +168,13 @@ namespace OpenSim.Services.AssetService public virtual string Store(AssetBase asset) { - bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0]; - if (!exists) + bool[] assetsexist = m_Database.AssetsExist([ asset.FullID ] ); + if (assetsexist.Length == 0 || !assetsexist[0]) { // m_log.DebugFormat( // "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length); if (!m_Database.StoreAsset(asset)) - { - return UUID.Zero.ToString(); - } + return UUID.Zero.ToString(); } // else // { diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs index 945e133de5..144c1b7a69 100644 --- a/OpenSim/Services/AssetService/XAssetService.cs +++ b/OpenSim/Services/AssetService/XAssetService.cs @@ -187,9 +187,8 @@ namespace OpenSim.Services.AssetService public virtual string Store(AssetBase asset) { - bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0]; - if (!exists) - { + bool[] assetsexist = m_Database.AssetsExist([ asset.FullID ] ); + if (assetsexist.Length == 0 || !assetsexist[0]) { // m_log.DebugFormat( // "[XASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length); m_Database.StoreAsset(asset);