diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 66de3608f8..a37c457092 100755 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -56,6 +56,7 @@ namespace OpenSim.Region.CoreModules.Asset { public string filename; public AssetBase asset; + public bool replace; } private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); @@ -212,21 +213,9 @@ namespace OpenSim.Region.CoreModules.Asset MainConsole.Instance.Commands.AddCommand("Assets", true, "fcache status", "fcache status", "Display cache status", HandleConsoleCommand); MainConsole.Instance.Commands.AddCommand("Assets", true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the cache. If file or memory is specified then only this cache is cleared.", HandleConsoleCommand); MainConsole.Instance.Commands.AddCommand("Assets", true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand); - MainConsole.Instance.Commands.AddCommand("Assets", true, "fcache expire", "fcache expire ", "Purge cached assets older then the specified date/time", HandleConsoleCommand); + MainConsole.Instance.Commands.AddCommand("Assets", true, "fcache expire", "fcache expire ", "Purge cached assets older than the specified date/time", HandleConsoleCommand); if (!string.IsNullOrWhiteSpace(m_assetLoader)) { - IAssetLoader assetLoader = ServerUtils.LoadPlugin(m_assetLoader, new object[] { }); - if (assetLoader != null) - { - HashSet ids = new HashSet(); - assetLoader.ForEachDefaultXmlAsset( - m_assetLoaderArgs, - delegate (AssetBase a) - { - ids.Add(a.ID); - }); - m_defaultAssets = ids; - } MainConsole.Instance.Commands.AddCommand("Assets", true, "fcache cachedefaultassets", "fcache cachedefaultassets", "loads local default assets to cache. This may override grid ones. use with care", HandleConsoleCommand); MainConsole.Instance.Commands.AddCommand("Assets", true, "fcache deletedefaultassets", "fcache deletedefaultassets", "deletes default local assets from cache so they can be refreshed from grid. use with care", HandleConsoleCommand); } @@ -316,6 +305,23 @@ namespace OpenSim.Region.CoreModules.Asset m_cancelSource = new CancellationTokenSource(); WorkManager.RunInThreadPool(ProcessWrites, null, "FloatsamCacheWriter", false); } + + if(!string.IsNullOrWhiteSpace(m_assetLoader) && scene.RegionInfo.RegionID == m_Scenes[0].RegionInfo.RegionID) + { + IAssetLoader assetLoader = ServerUtils.LoadPlugin(m_assetLoader, new object[] { }); + if (assetLoader != null) + { + HashSet ids = new HashSet(); + assetLoader.ForEachDefaultXmlAsset( + m_assetLoaderArgs, + delegate (AssetBase a) + { + Cache(a, true); + ids.Add(a.ID); + }); + m_defaultAssets = ids; + } + } } } } @@ -328,7 +334,7 @@ namespace OpenSim.Region.CoreModules.Asset { if(m_assetFileWriteQueue.TryTake(out WriteAssetInfo wai,-1, m_cancelSource.Token)) { - WriteFileCache(wai.filename,wai.asset,false); + WriteFileCache(wai.filename,wai.asset,wai.replace); wai.asset = null; Thread.Sleep(20); } @@ -385,7 +391,8 @@ namespace OpenSim.Region.CoreModules.Asset WriteAssetInfo wai = new WriteAssetInfo() { filename = filename, - asset = asset + asset = asset, + replace = replace }; if (m_assetFileWriteQueue != null) @@ -983,8 +990,13 @@ namespace OpenSim.Region.CoreModules.Asset File.Delete(filename); File.Move(tempname, filename); } - catch (IOException) + catch { + try + { + File.Delete(tempname); + } + catch{ } // If we see an IOException here it's likely that some other competing thread has written the // cache file first, so ignore. Other IOException errors (e.g. filesystem full) should be // signally by the earlier temporary file writing code.