1pub mod runtime;
2pub mod server;
3
4mod storage;
5pub use storage::{StorageBackend, StorageFactory};
6
7mod content_negotiation;
8mod fs_sync;
9
10mod ignore_filter;
11pub use ignore_filter::IgnoreFilter;
12
13use std::path::PathBuf;
14
15#[derive(Debug, Clone)]
16pub struct Config {
17 pub port: i32,
18 pub storage_dir: PathBuf,
19 pub sync_dir: Option<PathBuf>,
20 pub sync_write: bool,
21 pub sync_ignore: IgnoreFilter,
22 pub daemon: bool,
23 pub pidfile: Option<PathBuf>,
24 pub log_filename: Option<PathBuf>,
25}
26
27mod util {
28 use std::path::{Path, PathBuf};
29
30 pub fn path_stem(path: &Path) -> PathBuf {
32 let mut prefix = path;
34 while prefix.extension().is_some() {
35 prefix = Path::new(prefix.file_stem().unwrap());
36 }
37
38 match path.parent() {
39 None => prefix.into(),
40 Some(parent) => parent.join(prefix),
41 }
42 }
43
44 #[cfg(test)]
45 mod tests {
46 use super::*;
47
48 #[test]
49 fn test_path_stem() {
50 let path = Path::new("/foo/bar/baz.foy.txt");
51 assert_eq!(path_stem(path), PathBuf::from("/foo/bar/baz"));
52 }
53 }
54}