Remove default config files

This commit is contained in:
JustArchi
2018-10-07 03:21:32 +02:00
parent 2e37c955a3
commit 7c3cbc03f8
13 changed files with 63 additions and 135 deletions

5
.gitignore vendored
View File

@@ -2,9 +2,12 @@
## ArchiSteamFarm
#################
# Ignore all config files
# Ignore all files in config directory
ArchiSteamFarm/config
# Except placeholder to include the folder
!ArchiSteamFarm/config/.gitkeep
# Include default pre-defined config files
!ArchiSteamFarm/config/ASF.json
!ArchiSteamFarm/config/example.json

View File

@@ -253,8 +253,6 @@ namespace ArchiSteamFarm {
switch (botName) {
case SharedInfo.ASF:
case "example":
case "minimal":
return false;
default:
return true;
@@ -586,7 +584,7 @@ namespace ArchiSteamFarm {
Directory.CreateDirectory(directory);
}
if (string.IsNullOrEmpty(zipFile.Name) || zipFile.Name.Equals(SharedInfo.GlobalConfigFileName)) {
if (string.IsNullOrEmpty(zipFile.Name)) {
continue;
}

View File

@@ -107,13 +107,7 @@
<None Update="UI.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="config\ASF.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="config\example.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="config\minimal.json">
<None Update="config\.gitkeep">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="..\ASF-ui\dist\**\*.*" Exclude="**\README.md">

View File

@@ -861,7 +861,7 @@ namespace ArchiSteamFarm {
string databaseFilePath = botPath + SharedInfo.DatabaseExtension;
BotDatabase botDatabase = await BotDatabase.Load(databaseFilePath).ConfigureAwait(false);
BotDatabase botDatabase = await BotDatabase.CreateOrLoad(databaseFilePath).ConfigureAwait(false);
if (botDatabase == null) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorDatabaseInvalid, databaseFilePath));
return;

View File

@@ -144,6 +144,34 @@ namespace ArchiSteamFarm {
}
}
internal static async Task<BotDatabase> CreateOrLoad(string filePath) {
if (string.IsNullOrEmpty(filePath)) {
ASF.ArchiLogger.LogNullError(nameof(filePath));
return null;
}
if (!File.Exists(filePath)) {
return new BotDatabase(filePath);
}
BotDatabase botDatabase;
try {
botDatabase = JsonConvert.DeserializeObject<BotDatabase>(await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false));
} catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e);
return null;
}
if (botDatabase == null) {
ASF.ArchiLogger.LogNullError(nameof(botDatabase));
return null;
}
botDatabase.FilePath = filePath;
return botDatabase;
}
internal IReadOnlyCollection<ulong> GetBlacklistedFromTradesSteamIDs() => BlacklistedFromTradesSteamIDs;
internal (string Key, string Name) GetGameToRedeemInBackground() {
@@ -186,34 +214,6 @@ namespace ArchiSteamFarm {
return IdlingPriorityAppIDs.Contains(appID);
}
internal static async Task<BotDatabase> Load(string filePath) {
if (string.IsNullOrEmpty(filePath)) {
ASF.ArchiLogger.LogNullError(nameof(filePath));
return null;
}
if (!File.Exists(filePath)) {
return new BotDatabase(filePath);
}
BotDatabase botDatabase;
try {
botDatabase = JsonConvert.DeserializeObject<BotDatabase>(await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false));
} catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e);
return null;
}
if (botDatabase == null) {
ASF.ArchiLogger.LogNullError(nameof(botDatabase));
return null;
}
botDatabase.FilePath = filePath;
return botDatabase;
}
internal async Task MakeReadOnly() {
if (ReadOnly) {
return;

View File

@@ -246,6 +246,12 @@ namespace ArchiSteamFarm {
return Enum.IsDefined(typeof(EUpdateChannel), UpdateChannel) ? (true, null) : (false, string.Format(Strings.ErrorConfigPropertyInvalid, nameof(UpdateChannel), UpdateChannel));
}
internal static GlobalConfig Create() =>
new GlobalConfig {
ShouldSerializeEverything = false,
ShouldSerializeSensitiveDetails = false
};
internal static async Task<GlobalConfig> Load(string filePath) {
if (string.IsNullOrEmpty(filePath)) {
ASF.ArchiLogger.LogNullError(nameof(filePath));

View File

@@ -69,16 +69,7 @@ namespace ArchiSteamFarm {
PackagesRefreshSemaphore.Dispose();
}
internal HashSet<uint> GetPackageIDs(uint appID) {
if (appID == 0) {
ASF.ArchiLogger.LogNullError(nameof(appID));
return null;
}
return PackagesData.Where(package => package.Value.AppIDs?.Contains(appID) == true).Select(package => package.Key).ToHashSet();
}
internal static async Task<GlobalDatabase> Load(string filePath) {
internal static async Task<GlobalDatabase> CreateOrLoad(string filePath) {
if (string.IsNullOrEmpty(filePath)) {
ASF.ArchiLogger.LogNullError(nameof(filePath));
return null;
@@ -106,6 +97,15 @@ namespace ArchiSteamFarm {
return globalDatabase;
}
internal HashSet<uint> GetPackageIDs(uint appID) {
if (appID == 0) {
ASF.ArchiLogger.LogNullError(nameof(appID));
return null;
}
return PackagesData.Where(package => package.Value.AppIDs?.Contains(appID) == true).Select(package => package.Key).ToHashSet();
}
internal async Task RefreshPackages(Bot bot, IReadOnlyDictionary<uint, uint> packages) {
if ((bot == null) || (packages == null) || (packages.Count == 0)) {
ASF.ArchiLogger.LogNullError(nameof(bot) + " || " + nameof(packages));

View File

@@ -34,9 +34,8 @@ namespace ArchiSteamFarm.IPC {
internal static class ArchiKestrel {
private const string ConfigurationFile = nameof(IPC) + ".config";
internal static string WebsiteDirectory { get; private set; } = Path.Combine(SharedInfo.HomeDirectory, SharedInfo.WebsiteDirectory);
internal static HistoryTarget HistoryTarget { get; private set; }
internal static string WebsiteDirectory { get; private set; } = Path.Combine(SharedInfo.HomeDirectory, SharedInfo.WebsiteDirectory);
private static IWebHost KestrelWebHost;

View File

@@ -239,12 +239,16 @@ namespace ArchiSteamFarm {
private static async Task InitGlobalConfigAndLanguage() {
string globalConfigFile = Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalConfigFileName);
GlobalConfig = await GlobalConfig.Load(globalConfigFile).ConfigureAwait(false);
if (GlobalConfig == null) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorGlobalConfigNotLoaded, globalConfigFile));
await Task.Delay(5 * 1000).ConfigureAwait(false);
await Exit(1).ConfigureAwait(false);
return;
if (File.Exists(globalConfigFile)) {
GlobalConfig = await GlobalConfig.Load(globalConfigFile).ConfigureAwait(false);
if (GlobalConfig == null) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorGlobalConfigNotLoaded, globalConfigFile));
await Task.Delay(5 * 1000).ConfigureAwait(false);
await Exit(1).ConfigureAwait(false);
return;
}
} else {
GlobalConfig = GlobalConfig.Create();
}
if (Debugging.IsUserDebugging) {
@@ -312,7 +316,7 @@ namespace ArchiSteamFarm {
await Task.Delay(5 * 1000).ConfigureAwait(false);
}
GlobalDatabase = await GlobalDatabase.Load(globalDatabaseFile).ConfigureAwait(false);
GlobalDatabase = await GlobalDatabase.CreateOrLoad(globalDatabaseFile).ConfigureAwait(false);
if (GlobalDatabase == null) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorDatabaseInvalid, globalDatabaseFile));
await Task.Delay(5 * 1000).ConfigureAwait(false);

View File

View File

@@ -1,30 +0,0 @@
{
"AutoRestart": true,
"Blacklist": [],
"CommandPrefix": "!",
"ConfirmationsLimiterDelay": 10,
"ConnectionTimeout": 60,
"CurrentCulture": null,
"Debug": false,
"FarmingDelay": 15,
"GiftsLimiterDelay": 1,
"Headless": false,
"IdleFarmingPeriod": 8,
"InventoryLimiterDelay": 3,
"IPC": false,
"IPCPassword": null,
"LoginLimiterDelay": 10,
"MaxFarmingTime": 10,
"MaxTradeHoldDuration": 15,
"OptimizationMode": 0,
"Statistics": true,
"SteamMessagePrefix": "/me ",
"SteamOwnerID": 0,
"SteamProtocols": 5,
"UpdateChannel": 1,
"UpdatePeriod": 24,
"WebLimiterDelay": 200,
"WebProxy": null,
"WebProxyPassword": null,
"WebProxyUsername": null
}

View File

@@ -1,41 +0,0 @@
{
"AcceptGifts": false,
"AutoSteamSaleEvent": false,
"BotBehaviour": 0,
"CustomGamePlayedWhileFarming": null,
"CustomGamePlayedWhileIdle": null,
"Enabled": false,
"FarmingOrders": [],
"GamesPlayedWhileIdle": [],
"HoursUntilCardDrops": 3,
"IdlePriorityQueueOnly": false,
"IdleRefundableGames": true,
"LootableTypes": [
1,
3,
5
],
"MatchableTypes": [
5
],
"OnlineStatus": 1,
"PasswordFormat": 0,
"Paused": false,
"RedeemingPreferences": 0,
"SendOnFarmingFinished": false,
"SendTradePeriod": 0,
"ShutdownOnFarmingFinished": false,
"SteamLogin": null,
"SteamMasterClanID": 0,
"SteamParentalCode": null,
"SteamPassword": null,
"SteamTradeToken": null,
"SteamUserPermissions": {},
"TradingPreferences": 0,
"TransferableTypes": [
1,
3,
5
],
"UseLoginKeys": true
}

View File

@@ -1,5 +0,0 @@
{
"Enabled": false,
"SteamLogin": null,
"SteamPassword": null
}