|
|
@@ -13,24 +13,6 @@ use twfss::{Database, FileTree, ClientSideSync, FileSystemWatcher, Error, Synchr
|
|
13
|
13
|
|
|
14
|
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
|
16
|
struct SynchronizedDirectory {
|
|
35
|
17
|
path: OsString,
|
|
36
|
18
|
client_side_sync: ClientSideSync,
|
|
|
@@ -65,8 +47,8 @@ impl SynchronizedDirectory {
|
|
65
|
47
|
#[tokio::main]
|
|
66
|
48
|
async fn main() {
|
|
67
|
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
|
53
|
// Check whether the client is already running, and exit if it is.
|
|
72
|
54
|
fs::write(&paths::client_lock(), b"").ok();
|
|
|
@@ -87,7 +69,7 @@ async fn main() {
|
|
87
|
69
|
|
|
88
|
70
|
// Initialize the existing synchronized directories.
|
|
89
|
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
|
73
|
for directory in db.lock().await.synchronized_directories() {
|
|
92
|
74
|
// The function cannot fail - we just fetched the directory from the database.
|
|
93
|
75
|
let mut sync_dir = SynchronizedDirectory::open(db.clone(), &directory, errors_send.clone()).await.unwrap();
|