2016-10-24 12:58:57 -07:00
|
|
|
|
using System;
|
2016-08-30 15:02:48 -07:00
|
|
|
|
using System.Collections.Generic;
|
2018-02-09 20:36:39 -08:00
|
|
|
|
using System.Linq;
|
2016-10-24 12:58:57 -07:00
|
|
|
|
|
2017-05-04 02:41:11 -07:00
|
|
|
|
using SabreTools.Library.Data;
|
|
|
|
|
|
using SabreTools.Library.Help;
|
|
|
|
|
|
using SabreTools.Library.Tools;
|
2016-08-30 15:02:48 -07:00
|
|
|
|
|
2017-12-05 18:13:42 -08:00
|
|
|
|
#if MONO
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
#else
|
|
|
|
|
|
using Alphaleonis.Win32.Filesystem;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2017-02-02 15:08:21 -08:00
|
|
|
|
namespace RombaSharp
|
2016-08-30 15:02:48 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Entry class for the RombaSharp application
|
|
|
|
|
|
/// </summary>
|
2017-02-02 22:06:20 -08:00
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// In the database, we want to enable "offline mode". That is, when a user does an operation
|
|
|
|
|
|
/// that needs to read from the depot themselves, if the depot folder cannot be found, the
|
|
|
|
|
|
/// user is prompted to reconnect the depot OR skip that depot entirely.
|
|
|
|
|
|
/// </remarks>
|
2016-09-02 13:59:25 -07:00
|
|
|
|
public partial class RombaSharp
|
2016-08-30 15:02:48 -07:00
|
|
|
|
{
|
|
|
|
|
|
// General settings
|
2017-02-02 22:06:20 -08:00
|
|
|
|
private static string _logdir; // Log folder location
|
|
|
|
|
|
private static string _tmpdir; // Temp folder location
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static string _webdir; // Web frontend location
|
|
|
|
|
|
private static string _baddir; // Fail-to-unpack file folder location
|
|
|
|
|
|
private static int _verbosity; // Verbosity of the output
|
|
|
|
|
|
private static int _cores; // Forced CPU cores
|
2016-08-30 15:02:48 -07:00
|
|
|
|
|
|
|
|
|
|
// DatRoot settings
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static string _dats; // DatRoot folder location
|
|
|
|
|
|
private static string _db; // Database name
|
2016-08-30 15:02:48 -07:00
|
|
|
|
|
|
|
|
|
|
// Depot settings
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static Dictionary<string, Tuple<long, bool>> _depots; // Folder location, Max size
|
2016-08-30 15:02:48 -07:00
|
|
|
|
|
|
|
|
|
|
// Server settings
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static int _port; // Web server port
|
2016-08-30 15:02:48 -07:00
|
|
|
|
|
|
|
|
|
|
// Other private variables
|
2016-09-02 13:59:25 -07:00
|
|
|
|
private static string _config = "config.xml";
|
|
|
|
|
|
private static string _dbSchema = "rombasharp";
|
|
|
|
|
|
private static string _connectionString;
|
2017-02-02 15:08:21 -08:00
|
|
|
|
private static Help _help;
|
2016-08-30 15:02:48 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2016-09-02 13:59:25 -07:00
|
|
|
|
/// Entry class for the RombaSharp application
|
2016-08-30 15:02:48 -07:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
|
{
|
2016-09-02 13:42:18 -07:00
|
|
|
|
// Perform initial setup and verification
|
2017-03-01 21:26:27 -08:00
|
|
|
|
Globals.Logger = new Logger(true, "romba.log");
|
2017-02-02 15:08:21 -08:00
|
|
|
|
|
2016-09-02 13:59:25 -07:00
|
|
|
|
InitializeConfiguration();
|
2016-09-22 21:04:41 -07:00
|
|
|
|
DatabaseTools.EnsureDatabase(_dbSchema, _db, _connectionString);
|
2016-09-02 13:42:18 -07:00
|
|
|
|
|
2017-02-02 15:08:21 -08:00
|
|
|
|
// Create a new Help object for this program
|
2018-01-27 16:24:24 -08:00
|
|
|
|
_help = RombaSharp.RetrieveHelp();
|
2017-02-02 15:08:21 -08:00
|
|
|
|
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Get the location of the script tag, if it exists
|
|
|
|
|
|
int scriptLocation = (new List<string>(args)).IndexOf("--script");
|
|
|
|
|
|
|
|
|
|
|
|
// If output is being redirected or we are in script mode, don't allow clear screens
|
|
|
|
|
|
if (!Console.IsOutputRedirected && scriptLocation == -1)
|
2016-09-02 13:42:18 -07:00
|
|
|
|
{
|
|
|
|
|
|
Console.Clear();
|
2018-01-27 16:24:24 -08:00
|
|
|
|
Build.PrepareConsole("RombaSharp");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now we remove the script tag because it messes things up
|
|
|
|
|
|
if (scriptLocation > -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> newargs = new List<string>(args);
|
|
|
|
|
|
newargs.RemoveAt(scriptLocation);
|
|
|
|
|
|
args = newargs.ToArray();
|
2016-09-02 13:42:18 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Credits take precidence over all
|
|
|
|
|
|
if ((new List<string>(args)).Contains("--credits"))
|
|
|
|
|
|
{
|
2017-02-02 22:12:48 -08:00
|
|
|
|
_help.OutputCredits();
|
2017-03-01 21:26:27 -08:00
|
|
|
|
Globals.Logger.Close();
|
2016-09-02 13:42:18 -07:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If there's no arguments, show help
|
|
|
|
|
|
if (args.Length == 0)
|
|
|
|
|
|
{
|
2017-02-02 15:08:21 -08:00
|
|
|
|
_help.OutputGenericHelp();
|
2017-03-01 21:26:27 -08:00
|
|
|
|
Globals.Logger.Close();
|
2016-09-02 13:42:18 -07:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-10-20 16:00:54 -07:00
|
|
|
|
// User flags
|
|
|
|
|
|
bool copy = false,
|
2018-01-27 16:24:24 -08:00
|
|
|
|
fixdatOnly = false,
|
2017-02-02 22:06:20 -08:00
|
|
|
|
logOnly = false,
|
2018-01-27 16:24:24 -08:00
|
|
|
|
noDb = false,
|
|
|
|
|
|
onlyNeeded = false,
|
|
|
|
|
|
skipInitialScan = false,
|
|
|
|
|
|
useGolangZip = false;
|
2016-10-20 16:00:54 -07:00
|
|
|
|
|
|
|
|
|
|
// User inputs
|
2018-01-27 16:24:24 -08:00
|
|
|
|
string backup = "",
|
|
|
|
|
|
description = "",
|
|
|
|
|
|
missingSha1s = "",
|
|
|
|
|
|
name = "",
|
2017-02-02 21:57:34 -08:00
|
|
|
|
newdat = "",
|
2018-01-27 16:24:24 -08:00
|
|
|
|
old = "",
|
|
|
|
|
|
outdat = "",
|
|
|
|
|
|
resume = "",
|
|
|
|
|
|
source = "";
|
2018-02-09 20:14:19 -08:00
|
|
|
|
int include7Zips = 1,
|
|
|
|
|
|
includeGZips = 1,
|
|
|
|
|
|
includeZips = 1,
|
2018-01-27 16:24:24 -08:00
|
|
|
|
subworkers = 0,
|
|
|
|
|
|
workers = 0;
|
|
|
|
|
|
long size = -1;
|
|
|
|
|
|
List<string> dats = new List<string>();
|
|
|
|
|
|
List<string> depot = new List<string>();
|
2016-09-02 13:42:18 -07:00
|
|
|
|
List<string> inputs = new List<string>();
|
|
|
|
|
|
|
2017-12-05 18:13:42 -08:00
|
|
|
|
// Get the first argument as a feature flag
|
|
|
|
|
|
string feature = args[0];
|
|
|
|
|
|
|
|
|
|
|
|
// Verify that the flag is valid
|
|
|
|
|
|
if (!_help.TopLevelFlag(feature))
|
|
|
|
|
|
{
|
|
|
|
|
|
Globals.Logger.User("'{0}' is not valid feature flag", feature);
|
|
|
|
|
|
_help.OutputIndividualFeature(feature);
|
|
|
|
|
|
Globals.Logger.Close();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now get the proper name for the feature
|
|
|
|
|
|
feature = _help.GetFeatureName(feature);
|
|
|
|
|
|
|
|
|
|
|
|
// If we had the help feature first
|
|
|
|
|
|
if (feature == "Help")
|
2016-09-02 13:42:18 -07:00
|
|
|
|
{
|
2017-12-05 18:13:42 -08:00
|
|
|
|
// If we had something else after help
|
|
|
|
|
|
if (args.Length > 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
_help.OutputIndividualFeature(args[1]);
|
|
|
|
|
|
Globals.Logger.Close();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// Otherwise, show generic help
|
|
|
|
|
|
else
|
2016-09-02 13:42:18 -07:00
|
|
|
|
{
|
2017-12-05 18:13:42 -08:00
|
|
|
|
_help.OutputGenericHelp();
|
|
|
|
|
|
Globals.Logger.Close();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now verify that all other flags are valid
|
|
|
|
|
|
for (int i = 1; i < args.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Verify that the current flag is proper for the feature
|
|
|
|
|
|
if (!_help[feature].ValidateInput(args[i]))
|
|
|
|
|
|
{
|
2018-02-09 21:15:13 -08:00
|
|
|
|
// Everything else is treated as a generic input
|
|
|
|
|
|
inputs.Add(args[i]);
|
2017-12-05 18:13:42 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now loop through all inputs
|
|
|
|
|
|
Dictionary<string, Feature> features = _help.GetEnabledFeatures();
|
|
|
|
|
|
foreach (KeyValuePair<string, Feature> feat in features)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Check all of the flag names and translate to arguments
|
|
|
|
|
|
switch (feat.Key)
|
|
|
|
|
|
{
|
2018-01-27 16:24:24 -08:00
|
|
|
|
#region User Flags
|
|
|
|
|
|
|
2017-12-05 18:13:42 -08:00
|
|
|
|
case "copy":
|
2016-10-20 16:00:54 -07:00
|
|
|
|
copy = true;
|
|
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
case "fixdatOnly":
|
|
|
|
|
|
fixdatOnly = true;
|
|
|
|
|
|
break;
|
2017-12-05 18:13:42 -08:00
|
|
|
|
case "log-only":
|
2017-02-02 22:06:20 -08:00
|
|
|
|
logOnly = true;
|
|
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
case "no-db":
|
|
|
|
|
|
noDb = true;
|
|
|
|
|
|
break;
|
2017-12-05 18:13:42 -08:00
|
|
|
|
case "only-needed":
|
2016-10-20 16:00:54 -07:00
|
|
|
|
onlyNeeded = true;
|
|
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
case "skip-initial-scan":
|
|
|
|
|
|
skipInitialScan = true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "use-golang-zip":
|
|
|
|
|
|
useGolangZip = true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region User Int32 Inputs
|
|
|
|
|
|
|
|
|
|
|
|
case "include-7zips":
|
|
|
|
|
|
include7Zips = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 0;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "include-gzips":
|
|
|
|
|
|
includeGZips = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 0;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "include-zips":
|
|
|
|
|
|
includeZips = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 0;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "subworkers":
|
|
|
|
|
|
subworkers = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : _cores;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "workers":
|
|
|
|
|
|
workers = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : _cores;
|
|
|
|
|
|
break;
|
2016-10-20 16:00:54 -07:00
|
|
|
|
|
2018-01-27 16:24:24 -08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region User Int64 Inputs
|
|
|
|
|
|
|
|
|
|
|
|
case "size":
|
|
|
|
|
|
size = (long)feat.Value.GetValue() == Int64.MinValue ? (long)feat.Value.GetValue() : 0;
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region User List<string> Inputs
|
|
|
|
|
|
|
|
|
|
|
|
case "dats":
|
|
|
|
|
|
dats.AddRange((List<string>)feat.Value.GetValue());
|
|
|
|
|
|
break;
|
2017-12-05 18:13:42 -08:00
|
|
|
|
case "depot":
|
2018-01-27 16:24:24 -08:00
|
|
|
|
depot.AddRange((List<string>)feat.Value.GetValue());
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region User String Inputs
|
|
|
|
|
|
|
|
|
|
|
|
case "backup":
|
|
|
|
|
|
backup = (string)feat.Value.GetValue();
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "description":
|
|
|
|
|
|
description = (string)feat.Value.GetValue();
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "missingSha1s":
|
|
|
|
|
|
missingSha1s = (string)feat.Value.GetValue();
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "name":
|
|
|
|
|
|
name = (string)feat.Value.GetValue();
|
2017-02-02 21:57:34 -08:00
|
|
|
|
break;
|
2017-12-05 18:13:42 -08:00
|
|
|
|
case "new":
|
|
|
|
|
|
newdat = (string)feat.Value.GetValue();
|
2016-10-20 16:00:54 -07:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
case "old":
|
|
|
|
|
|
old = (string)feat.Value.GetValue();
|
|
|
|
|
|
break;
|
2017-12-05 18:13:42 -08:00
|
|
|
|
case "out":
|
|
|
|
|
|
outdat = (string)feat.Value.GetValue();
|
2016-09-02 13:42:18 -07:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
case "resume":
|
|
|
|
|
|
resume = (string)feat.Value.GetValue();
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "source":
|
|
|
|
|
|
source = (string)feat.Value.GetValue();
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2016-09-02 13:42:18 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now take care of each mode in succesion
|
2017-12-05 19:09:32 -08:00
|
|
|
|
switch(feature)
|
2016-10-12 16:51:42 -07:00
|
|
|
|
{
|
2017-12-05 19:09:32 -08:00
|
|
|
|
case "Help":
|
|
|
|
|
|
// No-op as this should be caught
|
|
|
|
|
|
break;
|
|
|
|
|
|
// Adds ROM files from the specified directories to the ROM archive
|
|
|
|
|
|
case "Archive":
|
2017-12-05 22:21:12 -08:00
|
|
|
|
VerifyInputs(inputs, feature);
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitArchive(inputs, onlyNeeded, resume, includeZips, workers, includeGZips, include7Zips, skipInitialScan, useGolangZip, noDb);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
|
|
|
|
|
// For each specified DAT file it creates the torrentzip files
|
|
|
|
|
|
case "Build":
|
2017-12-05 22:21:12 -08:00
|
|
|
|
VerifyInputs(inputs, feature);
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitBuild(inputs, outdat, fixdatOnly, copy, workers, subworkers);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Cancels current long-running job
|
|
|
|
|
|
case "Cancel":
|
|
|
|
|
|
InitCancel();
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Prints dat stats
|
|
|
|
|
|
case "DatStats":
|
2017-12-05 22:21:12 -08:00
|
|
|
|
VerifyInputs(inputs, feature);
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitDatStats(inputs);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Prints db stats
|
|
|
|
|
|
case "DbStats":
|
|
|
|
|
|
InitDbStats();
|
|
|
|
|
|
break;
|
|
|
|
|
|
// Creates a DAT file with those entries that are in -new DAT
|
2017-12-05 19:09:32 -08:00
|
|
|
|
case "Diffdat":
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitDiffDat(outdat, old, newdat, name, description);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Creates a DAT file for the specified input directory and saves it to the -out filename
|
2017-12-05 19:09:32 -08:00
|
|
|
|
case "Dir2Dat":
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitDir2Dat(outdat, source, name, description);
|
|
|
|
|
|
break;
|
|
|
|
|
|
// Creates a DAT file with those entries that are in -new DAT
|
|
|
|
|
|
case "EDiffdat":
|
|
|
|
|
|
InitEDiffDat(outdat, old, newdat);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Exports db to export.csv
|
2017-12-05 19:09:32 -08:00
|
|
|
|
case "Export":
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitExport();
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
|
|
|
|
|
// For each specified DAT file it creates a fix DAT
|
|
|
|
|
|
case "Fixdat":
|
2017-12-05 22:21:12 -08:00
|
|
|
|
VerifyInputs(inputs, feature);
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitFixdat(inputs, outdat, fixdatOnly, workers, subworkers);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Import a database from a formatted CSV file
|
2017-12-05 19:09:32 -08:00
|
|
|
|
case "Import":
|
2017-12-05 22:21:12 -08:00
|
|
|
|
VerifyInputs(inputs, feature);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
InitImport(inputs);
|
|
|
|
|
|
break;
|
|
|
|
|
|
// For each specified hash it looks up any available information
|
|
|
|
|
|
case "Lookup":
|
2017-12-05 22:21:12 -08:00
|
|
|
|
VerifyInputs(inputs, feature);
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitLookup(inputs, size, outdat);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
|
|
|
|
|
// Prints memory stats
|
|
|
|
|
|
case "Memstats":
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitMemstats();
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Merges depot
|
2017-12-05 19:09:32 -08:00
|
|
|
|
case "Merge":
|
2017-12-05 22:21:12 -08:00
|
|
|
|
VerifyInputs(inputs, feature);
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitMerge(inputs, onlyNeeded, resume, workers, skipInitialScan);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Create miss and have file
|
2017-12-05 19:09:32 -08:00
|
|
|
|
case "Miss":
|
2017-12-05 22:21:12 -08:00
|
|
|
|
VerifyInputs(inputs, feature);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
InitMiss(inputs);
|
|
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Shows progress of the currently running command
|
|
|
|
|
|
case "Progress":
|
|
|
|
|
|
InitProgress();
|
|
|
|
|
|
break;
|
2017-12-05 19:09:32 -08:00
|
|
|
|
// Moves DAT index entries for orphaned DATs
|
|
|
|
|
|
case "Purge Backup":
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitPurgeBackup(backup, workers, depot, dats, logOnly);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
|
|
|
|
|
// Deletes DAT index entries for orphaned DATs
|
|
|
|
|
|
case "Purge Delete":
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitPurgeDelete(workers, depot, dats, logOnly);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
|
|
|
|
|
// Refreshes the DAT index from the files in the DAT master directory tree
|
|
|
|
|
|
case "Refresh DATs":
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitRefreshDats(workers, missingSha1s);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Rescan a specific depot
|
|
|
|
|
|
case "Rescan Depots":
|
|
|
|
|
|
VerifyInputs(inputs, feature);
|
|
|
|
|
|
InitRescanDepots(inputs);
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// Gracefully shuts down server
|
2017-12-05 19:09:32 -08:00
|
|
|
|
case "Shutdown":
|
2018-01-27 16:24:24 -08:00
|
|
|
|
InitShutdown();
|
|
|
|
|
|
break;
|
|
|
|
|
|
// Prints version
|
|
|
|
|
|
case "Version":
|
|
|
|
|
|
InitVersion();
|
2017-12-05 19:09:32 -08:00
|
|
|
|
break;
|
2018-01-27 16:24:24 -08:00
|
|
|
|
// If nothing is set, show the help
|
2017-12-05 19:09:32 -08:00
|
|
|
|
default:
|
|
|
|
|
|
_help.OutputGenericHelp();
|
|
|
|
|
|
break;
|
2016-09-02 13:42:18 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-03-01 21:26:27 -08:00
|
|
|
|
Globals.Logger.Close();
|
2016-09-02 13:42:18 -07:00
|
|
|
|
return;
|
2016-08-30 15:02:48 -07:00
|
|
|
|
}
|
2017-12-05 22:21:12 -08:00
|
|
|
|
|
|
|
|
|
|
private static void VerifyInputs(List<string> inputs, string feature)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (inputs.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Globals.Logger.Error("This feature requires at least one input");
|
|
|
|
|
|
_help.OutputIndividualFeature(feature);
|
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-08-30 15:02:48 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|