aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-11-07 19:36:27 -0600
committerJP Dillingham <jpdillingham@gmail.com>2021-11-07 19:36:27 -0600
commitc62bb64823237ea7b413ff6e0b734e0eca30a870 (patch)
treeaa278779fc01835ae806e3f71ae69fa1ebf464ab /src
parent583c8d351677a7f0e9b8129eece6f21e6b3ab1cf (diff)
downloadslskd-c62bb64823237ea7b413ff6e0b734e0eca30a870.tar.gz
copy example config to app dir
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Program.cs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index db0f58b5..f649ce40 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -1,4 +1,4 @@
-// <copyright file="Program.cs" company="slskd Team">
+// <copyright file="Program.cs" company="slskd Team">
// Copyright (c) slskd Team. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
@@ -61,7 +61,7 @@ namespace slskd
/// <summary>
/// The default configuration filename.
/// </summary>
- public static readonly string DefaultConfigurationFile = Path.Combine(AppContext.BaseDirectory, "config", $"{AppName}.yml");
+ public static readonly string DefaultConfigurationFile = Path.Combine(DefaultAppDirectory, $"{AppName}.yml");
/// <summary>
/// The default incomplete download directory.
@@ -230,9 +230,7 @@ namespace slskd
try
{
VerifyDirectory(OptionsAtStartup.Directories.App, createIfMissing: true, verifyWriteable: true);
- VerifyDirectory(Path.Combine(OptionsAtStartup.Directories.App, "config"), createIfMissing: true, verifyWriteable: true);
VerifyDirectory(Path.Combine(OptionsAtStartup.Directories.App, "data"), createIfMissing: true, verifyWriteable: true);
- VerifyDirectory(Path.Combine(OptionsAtStartup.Directories.App, "files"), createIfMissing: true, verifyWriteable: true);
VerifyDirectory(OptionsAtStartup.Directories.Incomplete, createIfMissing: true, verifyWriteable: true);
VerifyDirectory(OptionsAtStartup.Directories.Downloads, createIfMissing: true, verifyWriteable: true);
@@ -243,6 +241,20 @@ namespace slskd
return;
}
+ try
+ {
+ // for convenience, try to copy the example configuration file to the application directory
+ // if any part fails, just move on silently.
+ var exampleFileName = $"{AppName}.example.yml";
+ var source = Path.Combine(AppContext.BaseDirectory, "config", exampleFileName);
+ var destination = Path.Combine(OptionsAtStartup.Directories.App, exampleFileName);
+ File.Copy(source, destination);
+ }
+ catch
+ {
+ // no-op
+ }
+
Log.Logger = (OptionsAtStartup.Debug ? new LoggerConfiguration().MinimumLevel.Debug() : new LoggerConfiguration().MinimumLevel.Information())
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("System.Net.Http.HttpClient", OptionsAtStartup.Debug ? LogEventLevel.Warning : LogEventLevel.Fatal)