Files
duplicati/Duplicati/Library/Main/ForestHash/FhOptions.cs
T
kenneth@hexad.dk a0521da54d Initial version of the new block-based storage format.
Still needs a work over in terms of error handling, progress reporting, warning output, refactoring etc.
Also misses the volume reuse/reclaim algorithms.
But it passes the unit tests now, with and without a local database.

git-svn-id: https://duplicati.googlecode.com/svn/sandboxes/Kenneth/ForestHash@1526 59da171f-624f-0410-aa54-27559c288bec
2013-02-12 21:43:14 +00:00

84 lines
2.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Duplicati.Library.Interface;
namespace Duplicati.Library.Main.ForestHash
{
public class FhOptions : Options
{
/// <summary>
/// The default block size for Foresthash
/// </summary>
private const string DEFAULT_FH_BLOCKSIZE = "10kb";
public FhOptions(Dictionary<string, string> options)
: base(options)
{
}
/// <summary>
/// List of commands relating to the ForestHash module
/// </summary>
public static IList<ICommandLineArgument> Commands
{
get
{
return new List<ICommandLineArgument>(new ICommandLineArgument[] {
new CommandLineArgument("fh-dbpath", CommandLineArgument.ArgumentType.Path, Strings.FhOptions.FhdbpathShort, Strings.FhOptions.FhdbpathLong),
new CommandLineArgument("fh-blocksize", CommandLineArgument.ArgumentType.Size, Strings.FhOptions.FhblocksizeShort, Strings.FhOptions.FhblocksizeLong, DEFAULT_FH_BLOCKSIZE),
#if DEBUG
new CommandLineArgument("fh-no-local-blocks", CommandLineArgument.ArgumentType.Boolean, "Prevents using local blocks for restore", "", "false"),
new CommandLineArgument("fh-no-local-db", CommandLineArgument.ArgumentType.Boolean, "Prevents using local database for restore", "", "false"),
#endif
});
}
}
/// <summary>
/// Gets the path to the database
/// </summary>
public string Fhdbpath
{
get
{
string tmp;
m_options.TryGetValue("fh-dbpath", out tmp);
return tmp;
}
}
/// <summary>
/// Gets the current block size
/// </summary>
public int Fhblocksize
{
get
{
string tmp;
if (!m_options.TryGetValue("fh-blocksize", out tmp))
tmp = DEFAULT_FH_BLOCKSIZE;
long t = Utility.Sizeparser.ParseSize(tmp, "kb");
if (t > int.MaxValue || t < 1024)
throw new ArgumentOutOfRangeException("FhBlocksize", string.Format("The blocksize cannot be less than {0}, nor larger than {1}", 1024, int.MaxValue));
return (int)t;
}
}
#if DEBUG
public bool NoLocalBlocks
{
get { return Utility.Utility.ParseBoolOption(m_options, "fh-no-local-blocks"); }
}
public bool NoLocalDb
{
get { return Utility.Utility.ParseBoolOption(m_options, "fh-no-local-db"); }
}
#endif
}
}