diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index 5c25ccb76c..3ebfdf8950 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Reflection;
using log4net;
@@ -60,6 +61,24 @@ namespace OpenSim.Framework.Console
public const string VectorSeparator = ",";
public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
+
+ ///
+ /// Check if the given file path exists.
+ ///
+ /// If not, warning is printed to the given console.
+ /// true if the file does not exist, false otherwise.
+ ///
+ ///
+ public static bool CheckFileDoesNotExist(ICommandConsole console, string path)
+ {
+ if (File.Exists(path))
+ {
+ console.OutputFormat("File {0} already exists. Please move or remove it.", path);
+ return false;
+ }
+
+ return true;
+ }
///
/// 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 cf870100a4..afe12003b1 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;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
+using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
@@ -209,6 +210,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
Guid id, string firstName, string lastName, string invPath, string pass, string savePath,
Dictionary options)
{
+ if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, savePath))
+ return false;
+
if (m_scenes.Count > 0)
{
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 2a87dc2a5f..970487a3d4 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -32,6 +32,8 @@ using System.Reflection;
using log4net;
using NDesk.Options;
using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@@ -117,7 +119,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
//
// foreach (string param in mainParams)
// m_log.DebugFormat("GOT PARAM [{0}]", param);
-
+
if (mainParams.Count > 2)
{
DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty);
@@ -150,14 +152,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
List mainParams = ops.Parse(cmdparams);
+ string path;
if (mainParams.Count > 2)
- {
- ArchiveRegion(mainParams[2], options);
- }
+ path = mainParams[2];
else
- {
- ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, options);
- }
+ path = DEFAULT_OAR_BACKUP_FILENAME;
+
+ if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, path))
+ return;
+
+ ArchiveRegion(path, options);
}
public void ArchiveRegion(string savePath, Dictionary options)
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index 41a1afd643..f0a35ad0a9 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
string fileName = string.Format("{0}.xml", objectUuid);
- if (File.Exists(fileName))
- {
- m_console.OutputFormat("File {0} already exists. Please move or remove it.", fileName);
+ if (!ConsoleUtil.CheckFileDoesNotExist(m_console, fileName))
return;
- }
using (XmlTextWriter xtw = new XmlTextWriter(fileName, Encoding.UTF8))
{
diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
index 41ec14f224..7639c6ce45 100644
--- a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
@@ -127,6 +127,9 @@ namespace OpenSim.Region.OptionalModules.Asset
}
string fileName = rawAssetId;
+
+ if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName))
+ return;
using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
{
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
index 46b0c672e2..4123f491bb 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
@@ -141,6 +141,9 @@ namespace OpenSim.Server.Handlers.Asset
}
string fileName = rawAssetId;
+
+ if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName))
+ return;
using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
{