aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-10-24 03:08:58 +0100
committerJustin Clark-Casey (justincc)2012-10-24 03:08:58 +0100
commitf76dceb90b5a76a7b6a5243c9032996c007c0cf5 (patch)
tree19b99bef42c0c56febfad10835027d3c6f101619 /OpenSim
parentAdd "dump object uuid" console command. This allows any object in the scene ... (diff)
downloadopensim-SC-f76dceb90b5a76a7b6a5243c9032996c007c0cf5.zip
opensim-SC-f76dceb90b5a76a7b6a5243c9032996c007c0cf5.tar.gz
opensim-SC-f76dceb90b5a76a7b6a5243c9032996c007c0cf5.tar.bz2
opensim-SC-f76dceb90b5a76a7b6a5243c9032996c007c0cf5.tar.xz
Get "save oar" and "save iar" to tell you in a more friendly manner if the filename to save already exists, rather than exception throwing.
Also changes ConsoleUtil.CheckFileExists to CheckFileDoesNotExist() since this is more meaningful in the context, even though it does result in double negatives.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Console/ConsoleUtil.cs19
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs18
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs5
-rw-r--r--OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs3
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerConnector.cs3
6 files changed, 41 insertions, 11 deletions
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index 5c25ccb..3ebfdf8 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO;
30using System.Linq; 31using System.Linq;
31using System.Reflection; 32using System.Reflection;
32using log4net; 33using log4net;
@@ -60,6 +61,24 @@ namespace OpenSim.Framework.Console
60 61
61 public const string VectorSeparator = ","; 62 public const string VectorSeparator = ",";
62 public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); 63 public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
64
65 /// <summary>
66 /// Check if the given file path exists.
67 /// </summary>
68 /// <remarks>If not, warning is printed to the given console.</remarks>
69 /// <returns>true if the file does not exist, false otherwise.</returns>
70 /// <param name='console'></param>
71 /// <param name='path'></param>
72 public static bool CheckFileDoesNotExist(ICommandConsole console, string path)
73 {
74 if (File.Exists(path))
75 {
76 console.OutputFormat("File {0} already exists. Please move or remove it.", path);
77 return false;
78 }
79
80 return true;
81 }
63 82
64 /// <summary> 83 /// <summary>
65 /// Try to parse a console UUID from the console. 84 /// Try to parse a console UUID from the console.
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index cf87010..afe1200 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -35,6 +35,7 @@ using Nini.Config;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Console;
38using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 41using OpenSim.Services.Interfaces;
@@ -209,6 +210,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
209 Guid id, string firstName, string lastName, string invPath, string pass, string savePath, 210 Guid id, string firstName, string lastName, string invPath, string pass, string savePath,
210 Dictionary<string, object> options) 211 Dictionary<string, object> options)
211 { 212 {
213 if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, savePath))
214 return false;
215
212 if (m_scenes.Count > 0) 216 if (m_scenes.Count > 0)
213 { 217 {
214 UserAccount userInfo = GetUserInfo(firstName, lastName, pass); 218 UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index 2a87dc2..970487a 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -32,6 +32,8 @@ using System.Reflection;
32using log4net; 32using log4net;
33using NDesk.Options; 33using NDesk.Options;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Framework.Console;
35using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
37 39
@@ -117,7 +119,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
117// 119//
118// foreach (string param in mainParams) 120// foreach (string param in mainParams)
119// m_log.DebugFormat("GOT PARAM [{0}]", param); 121// m_log.DebugFormat("GOT PARAM [{0}]", param);
120 122
121 if (mainParams.Count > 2) 123 if (mainParams.Count > 2)
122 { 124 {
123 DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty); 125 DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty);
@@ -150,14 +152,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
150 152
151 List<string> mainParams = ops.Parse(cmdparams); 153 List<string> mainParams = ops.Parse(cmdparams);
152 154
155 string path;
153 if (mainParams.Count > 2) 156 if (mainParams.Count > 2)
154 { 157 path = mainParams[2];
155 ArchiveRegion(mainParams[2], options);
156 }
157 else 158 else
158 { 159 path = DEFAULT_OAR_BACKUP_FILENAME;
159 ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, options); 160
160 } 161 if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, path))
162 return;
163
164 ArchiveRegion(path, options);
161 } 165 }
162 166
163 public void ArchiveRegion(string savePath, Dictionary<string, object> options) 167 public void ArchiveRegion(string savePath, Dictionary<string, object> options)
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index 41a1afd..f0a35ad 100644
--- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -485,11 +485,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
485 485
486 string fileName = string.Format("{0}.xml", objectUuid); 486 string fileName = string.Format("{0}.xml", objectUuid);
487 487
488 if (File.Exists(fileName)) 488 if (!ConsoleUtil.CheckFileDoesNotExist(m_console, fileName))
489 {
490 m_console.OutputFormat("File {0} already exists. Please move or remove it.", fileName);
491 return; 489 return;
492 }
493 490
494 using (XmlTextWriter xtw = new XmlTextWriter(fileName, Encoding.UTF8)) 491 using (XmlTextWriter xtw = new XmlTextWriter(fileName, Encoding.UTF8))
495 { 492 {
diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
index 41ec14f..7639c6c 100644
--- a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
@@ -127,6 +127,9 @@ namespace OpenSim.Region.OptionalModules.Asset
127 } 127 }
128 128
129 string fileName = rawAssetId; 129 string fileName = rawAssetId;
130
131 if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName))
132 return;
130 133
131 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) 134 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
132 { 135 {
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
index 46b0c67..4123f49 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
@@ -141,6 +141,9 @@ namespace OpenSim.Server.Handlers.Asset
141 } 141 }
142 142
143 string fileName = rawAssetId; 143 string fileName = rawAssetId;
144
145 if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName))
146 return;
144 147
145 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) 148 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
146 { 149 {