浏览代码

client: Fix duplicated path definitions.

父节点
当前提交
8b835f54b0
共有 1 个文件被更改,包括 3 次插入21 次删除
  1. 3
    21
      src/bin/client.rs

+ 3
- 21
src/bin/client.rs 查看文件

13
 
13
 
14
 mod cli;
14
 mod cli;
15
 
15
 
16
-fn config_dir() -> String {
17
-    format!(
18
-        "{}/.config/twfss",
19
-        dirs::home_dir().unwrap().to_str().unwrap().to_owned()
20
-    )
21
-}
22
-
23
-fn data_dir() -> String {
24
-    format!(
25
-        "{}/.local/share/twfss-client",
26
-        dirs::home_dir().unwrap().to_str().unwrap().to_owned()
27
-    )
28
-}
29
-
30
-fn db_path() -> String {
31
-    format!("{}/client.db", data_dir())
32
-}
33
-
34
 struct SynchronizedDirectory {
16
 struct SynchronizedDirectory {
35
     path: OsString,
17
     path: OsString,
36
     client_side_sync: ClientSideSync,
18
     client_side_sync: ClientSideSync,
65
 #[tokio::main]
47
 #[tokio::main]
66
 async fn main() {
48
 async fn main() {
67
     // Create the data directories if necessary.
49
     // Create the data directories if necessary.
68
-    create_dir_all(config_dir()).unwrap();
69
-    create_dir_all(data_dir()).unwrap();
50
+    create_dir_all(paths::config_dir()).unwrap();
51
+    create_dir_all(paths::client_data()).unwrap();
70
 
52
 
71
     // Check whether the client is already running, and exit if it is.
53
     // Check whether the client is already running, and exit if it is.
72
     fs::write(&paths::client_lock(), b"").ok();
54
     fs::write(&paths::client_lock(), b"").ok();
87
 
69
 
88
     // Initialize the existing synchronized directories.
70
     // Initialize the existing synchronized directories.
89
     let mut directories = Vec::new();
71
     let mut directories = Vec::new();
90
-    let db = Arc::new(Mutex::new(Database::create_or_open(&db_path()).unwrap()));
72
+    let db = Arc::new(Mutex::new(Database::create_or_open(&paths::client_db()).unwrap()));
91
     for directory in db.lock().await.synchronized_directories() {
73
     for directory in db.lock().await.synchronized_directories() {
92
         // The function cannot fail - we just fetched the directory from the database.
74
         // The function cannot fail - we just fetched the directory from the database.
93
         let mut sync_dir = SynchronizedDirectory::open(db.clone(), &directory, errors_send.clone()).await.unwrap();
75
         let mut sync_dir = SynchronizedDirectory::open(db.clone(), &directory, errors_send.clone()).await.unwrap();

正在加载...
取消
保存