From f76dceb90b5a76a7b6a5243c9032996c007c0cf5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Oct 2012 03:08:58 +0100 Subject: 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. --- .../Inventory/Archiver/InventoryArchiverModule.cs | 4 ++++ .../CoreModules/World/Archiver/ArchiverModule.cs | 18 +++++++++++------- .../World/Objects/Commands/ObjectCommandsModule.cs | 5 +---- 3 files changed, 16 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/CoreModules') 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; 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 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; 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 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 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)) { -- cgit v1.1