Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Move check to allow only deletion of maptiles up to AssetServerDelete…

…Handler from AssetService.

This allows us to use a common check for both AssetService and XAssetService.
It also allows future console commands to delete an asset.
As before, deletion of maptile assets is not allowed remotely unless this is explicitly configured.
  • Loading branch information...
commit 462ad336dcd59dfc4325aed9e6d635aa866cd094 1 parent 8dfe59d
Justin Clark-Casey authored
17  OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Server.Handlers.Asset
44 44
 {
45 45
     public class AssetServerDeleteHandler : BaseStreamHandler
46 46
     {
47  
-        // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  47
+        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
 
49 49
         private IAssetService m_AssetService;
50 50
         protected bool m_allowDelete;
@@ -65,11 +65,22 @@ public class AssetServerDeleteHandler : BaseStreamHandler
65 65
 
66 66
             if (p.Length > 0 && m_allowDelete)
67 67
             {
68  
-                result = m_AssetService.Delete(p[0]);
  68
+                string assetID = p[0];
  69
+
  70
+                AssetBase asset = m_AssetService.Get(assetID);
  71
+                if (asset != null && (int)(asset.Flags & AssetFlags.Maptile) != 0)
  72
+                {
  73
+                    result = m_AssetService.Delete(assetID);
  74
+                }
  75
+                else
  76
+                {
  77
+                    m_log.DebugFormat(
  78
+                        "[ASSET SERVER DELETE HANDLER]: Request to delete asset {0}, but flags are not Maptile", assetID);
  79
+                }
69 80
             }
70 81
 
71 82
             XmlSerializer xs = new XmlSerializer(typeof(bool));
72 83
             return ServerUtils.SerializeResult(xs, result);
73 84
         }
74 85
     }
75  
-}
  86
+}
17  OpenSim/Services/AssetService/AssetService.cs
@@ -70,7 +70,7 @@ public AssetService(IConfigSource config, string configName) : base(config, conf
70 70
 
71 71
                     if (assetLoaderEnabled)
72 72
                     {
73  
-                        m_log.DebugFormat("[ASSET]: Loading default asset set from {0}", loaderArgs);
  73
+                        m_log.DebugFormat("[ASSET SERVICE]: Loading default asset set from {0}", loaderArgs);
74 74
 
75 75
                         m_AssetLoader.ForEachDefaultXmlAsset(
76 76
                             loaderArgs,
@@ -197,20 +197,7 @@ public virtual bool Delete(string id)
197 197
             if (!UUID.TryParse(id, out assetID))
198 198
                 return false;
199 199
 
200  
-            AssetBase asset = m_Database.GetAsset(assetID);
201  
-            if (asset == null)
202  
-                return false;
203  
-
204  
-            if ((int)(asset.Flags & AssetFlags.Maptile) != 0)
205  
-            {
206  
-                return m_Database.Delete(id);
207  
-            }
208  
-            else
209  
-            {
210  
-                m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id);
211  
-            }
212  
-
213  
-            return false;
  200
+            return m_Database.Delete(id);
214 201
         }
215 202
     }
216 203
 }
18  OpenSim/Services/AssetService/XAssetService.cs
@@ -194,21 +194,7 @@ public virtual bool Delete(string id)
194 194
             if (!UUID.TryParse(id, out assetID))
195 195
                 return false;
196 196
 
197  
-            AssetBase asset = m_Database.GetAsset(assetID);
198  
-            if (asset == null)
199  
-                return false;
200  
-
201  
-            if ((int)(asset.Flags & AssetFlags.Maptile) != 0)
202  
-            {
203  
-                return m_Database.Delete(id);
204  
-            }
205  
-            else
206  
-            {
207  
-                m_log.DebugFormat("[XASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id);
208  
-            }
209  
-
210  
-            return false;
  197
+            return m_Database.Delete(id);
211 198
         }
212 199
     }
213  
-}
214  
-
  200
+}

0 notes on commit 462ad33

Please sign in to comment.
Something went wrong with that request. Please try again.