|
|
@@ -9,35 +9,19 @@ use log::*;
|
|
9
|
9
|
use tokio::net::{TcpListener, TcpStream};
|
|
10
|
10
|
use tokio::stream::StreamExt;
|
|
11
|
11
|
|
|
12
|
|
-use twfss::Database;
|
|
13
|
|
-
|
|
14
|
|
-fn config_dir() -> String {
|
|
15
|
|
- format!(
|
|
16
|
|
- "{}/.config/twfss",
|
|
17
|
|
- dirs::home_dir().unwrap().to_str().unwrap().to_owned()
|
|
18
|
|
- )
|
|
19
|
|
-}
|
|
20
|
|
-
|
|
21
|
|
-fn data_dir() -> String {
|
|
22
|
|
- format!(
|
|
23
|
|
- "{}/.local/share/twfss-server",
|
|
24
|
|
- dirs::home_dir().unwrap().to_str().unwrap().to_owned()
|
|
25
|
|
- )
|
|
26
|
|
-}
|
|
27
|
|
-
|
|
28
|
|
-fn db_path() -> String {
|
|
29
|
|
- format!("{}/server.db", data_dir())
|
|
30
|
|
-}
|
|
|
12
|
+use twfss::{paths, Database};
|
|
31
|
13
|
|
|
32
|
14
|
#[tokio::main]
|
|
33
|
15
|
async fn main() {
|
|
34
|
16
|
env_logger::init();
|
|
35
|
17
|
|
|
36
|
18
|
// Create the configuration directory if necessary.
|
|
37
|
|
- create_dir_all(config_dir()).unwrap();
|
|
|
19
|
+ create_dir_all(paths::config_dir()).unwrap();
|
|
38
|
20
|
|
|
39
|
21
|
// Read configuration.
|
|
40
|
|
- let _db = Arc::new(Mutex::new(Database::create_or_open(&db_path()).unwrap()));
|
|
|
22
|
+ let _db = Arc::new(Mutex::new(
|
|
|
23
|
+ Database::create_or_open(&paths::server_db()).unwrap(),
|
|
|
24
|
+ ));
|
|
41
|
25
|
// TODO
|
|
42
|
26
|
|
|
43
|
27
|
// Start a thread that periodically checks whether the maximum database size
|