Change storages to be resolved by name instead of path on init

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 307b8c400c
commit 1c633d9581

@ -77,9 +77,9 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308" checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -88,9 +88,9 @@ version = "0.1.51"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -127,9 +127,9 @@ checksum = "ec107f431ee3d8a8e45e6dd117adab769556ef463959e77bf6a4888d5fd500cf"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error 0.4.12", "proc-macro-error 0.4.12",
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -433,7 +433,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db" checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db"
dependencies = [ dependencies = [
"data-encoding", "data-encoding",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -565,9 +565,9 @@ checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"proc-macro-hack", "proc-macro-hack",
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -829,10 +829,11 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]] [[package]]
name = "mediarepo-api" name = "mediarepo-api"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=e5bccc31eaedb1aed5973be98852b9c2632ed62d#e5bccc31eaedb1aed5973be98852b9c2632ed62d" source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=faf363da10c22cb2d7262ed7fe27301583fcbb9a#faf363da10c22cb2d7262ed7fe27301583fcbb9a"
dependencies = [ dependencies = [
"chrono", "chrono",
"serde", "serde",
"serde_piecewise_default",
"thiserror", "thiserror",
"tracing", "tracing",
] ]
@ -1032,9 +1033,9 @@ checksum = "424f6e86263cd5294cbd7f1e95746b95aca0e0d66bff31e5a40d6baa87b4aa99"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro-error 1.0.4", "proc-macro-error 1.0.4",
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"synstructure", "synstructure",
] ]
@ -1229,9 +1230,9 @@ version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389" checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1287,9 +1288,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7" checksum = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7"
dependencies = [ dependencies = [
"proc-macro-error-attr 0.4.12", "proc-macro-error-attr 0.4.12",
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"version_check", "version_check",
] ]
@ -1300,9 +1301,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [ dependencies = [
"proc-macro-error-attr 1.0.4", "proc-macro-error-attr 1.0.4",
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"version_check", "version_check",
] ]
@ -1312,9 +1313,9 @@ version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de" checksum = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"syn-mid", "syn-mid",
"version_check", "version_check",
] ]
@ -1325,8 +1326,8 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"version_check", "version_check",
] ]
@ -1342,13 +1343,31 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid 0.1.0",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.30" version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70" checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70"
dependencies = [ dependencies = [
"unicode-xid", "unicode-xid 0.2.2",
]
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
dependencies = [
"proc-macro2 0.4.30",
] ]
[[package]] [[package]]
@ -1357,7 +1376,7 @@ version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
] ]
[[package]] [[package]]
@ -1572,9 +1591,9 @@ dependencies = [
"bae", "bae",
"convert_case", "convert_case",
"heck", "heck",
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1597,9 +1616,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34cdc022b4f606353fe5dc85b09713a04e433323b70163e81513b141c6ae6eb5" checksum = "34cdc022b4f606353fe5dc85b09713a04e433323b70163e81513b141c6ae6eb5"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"thiserror", "thiserror",
] ]
@ -1619,9 +1638,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51c247af6c2c4ffd372fe97e9afa579b4438e4c306c9aa3f11cbf72f1e845180" checksum = "51c247af6c2c4ffd372fe97e9afa579b4438e4c306c9aa3f11cbf72f1e845180"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1662,9 +1681,9 @@ version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1679,6 +1698,28 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "serde_piecewise_default"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d91a44b0f51aedd237f8f25c831e1f629982a187a5045c08ce4bccccce17b4b0"
dependencies = [
"serde",
"serde_piecewise_default_derive",
]
[[package]]
name = "serde_piecewise_default_derive"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19446953e7b22342c23c79ede938c04b1c12f4eb7513db30cda94193ce30ff2a"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"serde",
"syn 0.15.44",
]
[[package]] [[package]]
name = "sha2" name = "sha2"
version = "0.9.8" version = "0.9.8"
@ -1804,13 +1845,13 @@ dependencies = [
"either", "either",
"heck", "heck",
"once_cell", "once_cell",
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"serde_json", "serde_json",
"sha2", "sha2",
"sqlx-core", "sqlx-core",
"sqlx-rt", "sqlx-rt",
"syn", "syn 1.0.80",
"url", "url",
] ]
@ -1861,9 +1902,20 @@ checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error 1.0.4", "proc-macro-error 1.0.4",
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
]
[[package]]
name = "syn"
version = "0.15.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"unicode-xid 0.1.0",
] ]
[[package]] [[package]]
@ -1872,9 +1924,9 @@ version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"unicode-xid", "unicode-xid 0.2.2",
] ]
[[package]] [[package]]
@ -1883,9 +1935,9 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9" checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1894,10 +1946,10 @@ version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"unicode-xid", "unicode-xid 0.2.2",
] ]
[[package]] [[package]]
@ -1938,9 +1990,9 @@ version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -2032,9 +2084,9 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2dd85aeaba7b68df939bd357c6afb36c87951be9e80bf9c859f2fc3e9fca0fd" checksum = "b2dd85aeaba7b68df939bd357c6afb36c87951be9e80bf9c859f2fc3e9fca0fd"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -2096,9 +2148,9 @@ version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -2234,6 +2286,12 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.2" version = "0.2.2"
@ -2317,9 +2375,9 @@ dependencies = [
"bumpalo", "bumpalo",
"lazy_static", "lazy_static",
"log", "log",
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -2329,7 +2387,7 @@ version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9"
dependencies = [ dependencies = [
"quote", "quote 1.0.10",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
] ]
@ -2339,9 +2397,9 @@ version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.30",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]

@ -9,7 +9,7 @@ repository = "https://github.com/Trivernis/mediarepo-daemon"
[[bin]] [[bin]]
name = "mediarepo" name = "mediarepo-daemon"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]

@ -63,14 +63,14 @@ impl Repo {
/// Sets the main storage /// Sets the main storage
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]
pub async fn set_main_storage<S: ToString + Debug>(&mut self, path: S) -> RepoResult<()> { pub async fn set_main_storage<S: ToString + Debug>(&mut self, path: S) -> RepoResult<()> {
self.main_storage = Storage::by_path(self.db.clone(), path).await?; self.main_storage = Storage::by_name(self.db.clone(), path.to_string()).await?;
Ok(()) Ok(())
} }
/// Sets the default thumbnail storage /// Sets the default thumbnail storage
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]
pub async fn set_thumbnail_storage<S: ToString + Debug>(&mut self, path: S) -> RepoResult<()> { pub async fn set_thumbnail_storage<S: ToString + Debug>(&mut self, path: S) -> RepoResult<()> {
self.thumbnail_storage = Storage::by_path(self.db.clone(), path).await?; self.thumbnail_storage = Storage::by_name(self.db.clone(), path.to_string()).await?;
Ok(()) Ok(())
} }

@ -52,6 +52,24 @@ impl Storage {
} }
} }
/// Returns the storage by name
#[tracing::instrument(level = "debug", skip(db))]
pub async fn by_name<S: AsRef<str> + Debug>(
db: DatabaseConnection,
name: S,
) -> RepoResult<Option<Self>> {
if let Some(model) = storage::Entity::find()
.filter(storage::Column::Name.eq(name.as_ref()))
.one(&db)
.await?
{
let storage = Self::new(db, model);
Ok(Some(storage))
} else {
Ok(None)
}
}
/// Returns the storage by path /// Returns the storage by path
#[tracing::instrument(level = "debug", skip(db))] #[tracing::instrument(level = "debug", skip(db))]
pub async fn by_path<S: ToString + Debug>( pub async fn by_path<S: ToString + Debug>(

@ -59,9 +59,9 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308" checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -70,9 +70,9 @@ version = "0.1.51"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -98,9 +98,9 @@ checksum = "ec107f431ee3d8a8e45e6dd117adab769556ef463959e77bf6a4888d5fd500cf"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error 0.4.12", "proc-macro-error 0.4.12",
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -389,7 +389,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db" checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db"
dependencies = [ dependencies = [
"data-encoding", "data-encoding",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -521,9 +521,9 @@ checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"proc-macro-hack", "proc-macro-hack",
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -770,10 +770,11 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]] [[package]]
name = "mediarepo-api" name = "mediarepo-api"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=e5bccc31eaedb1aed5973be98852b9c2632ed62d#e5bccc31eaedb1aed5973be98852b9c2632ed62d" source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=faf363da10c22cb2d7262ed7fe27301583fcbb9a#faf363da10c22cb2d7262ed7fe27301583fcbb9a"
dependencies = [ dependencies = [
"chrono", "chrono",
"serde", "serde",
"serde_piecewise_default",
"thiserror", "thiserror",
"tracing", "tracing",
] ]
@ -954,9 +955,9 @@ checksum = "424f6e86263cd5294cbd7f1e95746b95aca0e0d66bff31e5a40d6baa87b4aa99"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro-error 1.0.4", "proc-macro-error 1.0.4",
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"synstructure", "synstructure",
] ]
@ -1151,9 +1152,9 @@ version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389" checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1209,9 +1210,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7" checksum = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7"
dependencies = [ dependencies = [
"proc-macro-error-attr 0.4.12", "proc-macro-error-attr 0.4.12",
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"version_check", "version_check",
] ]
@ -1222,9 +1223,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [ dependencies = [
"proc-macro-error-attr 1.0.4", "proc-macro-error-attr 1.0.4",
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"version_check", "version_check",
] ]
@ -1234,9 +1235,9 @@ version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de" checksum = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"syn-mid", "syn-mid",
"version_check", "version_check",
] ]
@ -1247,8 +1248,8 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"version_check", "version_check",
] ]
@ -1264,13 +1265,31 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid 0.1.0",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.29" version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d"
dependencies = [ dependencies = [
"unicode-xid", "unicode-xid 0.2.2",
]
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
dependencies = [
"proc-macro2 0.4.30",
] ]
[[package]] [[package]]
@ -1279,7 +1298,7 @@ version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
] ]
[[package]] [[package]]
@ -1470,9 +1489,9 @@ dependencies = [
"bae", "bae",
"convert_case", "convert_case",
"heck", "heck",
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1495,9 +1514,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34cdc022b4f606353fe5dc85b09713a04e433323b70163e81513b141c6ae6eb5" checksum = "34cdc022b4f606353fe5dc85b09713a04e433323b70163e81513b141c6ae6eb5"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"thiserror", "thiserror",
] ]
@ -1517,9 +1536,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51c247af6c2c4ffd372fe97e9afa579b4438e4c306c9aa3f11cbf72f1e845180" checksum = "51c247af6c2c4ffd372fe97e9afa579b4438e4c306c9aa3f11cbf72f1e845180"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1560,9 +1579,9 @@ version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1577,6 +1596,28 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "serde_piecewise_default"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d91a44b0f51aedd237f8f25c831e1f629982a187a5045c08ce4bccccce17b4b0"
dependencies = [
"serde",
"serde_piecewise_default_derive",
]
[[package]]
name = "serde_piecewise_default_derive"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19446953e7b22342c23c79ede938c04b1c12f4eb7513db30cda94193ce30ff2a"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"serde",
"syn 0.15.44",
]
[[package]] [[package]]
name = "sha2" name = "sha2"
version = "0.9.8" version = "0.9.8"
@ -1693,13 +1734,13 @@ dependencies = [
"either", "either",
"heck", "heck",
"once_cell", "once_cell",
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"serde_json", "serde_json",
"sha2", "sha2",
"sqlx-core", "sqlx-core",
"sqlx-rt", "sqlx-rt",
"syn", "syn 1.0.80",
"url", "url",
] ]
@ -1725,15 +1766,26 @@ dependencies = [
"unicode-normalization", "unicode-normalization",
] ]
[[package]]
name = "syn"
version = "0.15.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"unicode-xid 0.1.0",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.80" version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"unicode-xid", "unicode-xid 0.2.2",
] ]
[[package]] [[package]]
@ -1742,9 +1794,9 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9" checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1753,10 +1805,10 @@ version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"unicode-xid", "unicode-xid 0.2.2",
] ]
[[package]] [[package]]
@ -1788,9 +1840,9 @@ version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1904,9 +1956,9 @@ version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
] ]
[[package]] [[package]]
@ -1971,6 +2023,12 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.2" version = "0.2.2"
@ -2048,9 +2106,9 @@ dependencies = [
"bumpalo", "bumpalo",
"lazy_static", "lazy_static",
"log", "log",
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -2060,7 +2118,7 @@ version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9"
dependencies = [ dependencies = [
"quote", "quote 1.0.10",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
] ]
@ -2070,9 +2128,9 @@ version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2 1.0.29",
"quote", "quote 1.0.10",
"syn", "syn 1.0.80",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]

@ -33,4 +33,4 @@ features = ["tokio-executor"]
[dependencies.mediarepo-api] [dependencies.mediarepo-api]
git = "https://github.com/Trivernis/mediarepo-api.git" git = "https://github.com/Trivernis/mediarepo-api.git"
rev = "e5bccc31eaedb1aed5973be98852b9c2632ed62d" rev = "faf363da10c22cb2d7262ed7fe27301583fcbb9a"

@ -11,10 +11,10 @@ pub fn get_builder(address: &str) -> IPCBuilder {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn info(ctx: &Context, event: Event) -> IPCResult<()> { async fn info(ctx: &Context, event: Event) -> IPCResult<()> {
let response = InfoResponse { let response = InfoResponse::new(
name: env!("CARGO_PKG_NAME").to_string(), env!("CARGO_PKG_NAME").to_string(),
version: env!("CARGO_PKG_VERSION").to_string(), env!("CARGO_PKG_VERSION").to_string(),
}; );
ctx.emitter ctx.emitter
.emit_response(event.id(), "info", response) .emit_response(event.id(), "info", response)
.await?; .await?;

@ -16,6 +16,7 @@ use mediarepo_model::repo::Repo;
use mediarepo_model::type_keys::RepoKey; use mediarepo_model::type_keys::RepoKey;
use mediarepo_socket::get_builder; use mediarepo_socket::get_builder;
use num_integer::Integer; use num_integer::Integer;
use std::env;
use crate::constants::{DEFAULT_STORAGE_NAME, SETTINGS_PATH, THUMBNAIL_STORAGE_NAME}; use crate::constants::{DEFAULT_STORAGE_NAME, SETTINGS_PATH, THUMBNAIL_STORAGE_NAME};
use crate::utils::{create_paths_for_repo, get_repo, load_settings}; use crate::utils::{create_paths_for_repo, get_repo, load_settings};
@ -65,7 +66,12 @@ enum SubCommand {
} }
fn main() -> RepoResult<()> { fn main() -> RepoResult<()> {
let opt: Opt = Opt::from_args(); let mut opt: Opt = Opt::from_args();
opt.repo = env::current_dir()
.unwrap()
.join(opt.repo)
.canonicalize()
.unwrap();
let mut _guard = None; let mut _guard = None;
if opt.profile { if opt.profile {
_guard = Some(logging::init_tracing_flame()); _guard = Some(logging::init_tracing_flame());
@ -105,11 +111,9 @@ fn get_multi_thread_runtime() -> Runtime {
async fn init_repo(opt: &Opt) -> RepoResult<(Settings, Repo)> { async fn init_repo(opt: &Opt) -> RepoResult<(Settings, Repo)> {
let settings = load_settings(&opt.repo.join(SETTINGS_PATH)).await?; let settings = load_settings(&opt.repo.join(SETTINGS_PATH)).await?;
let mut repo = get_repo(&opt.repo.join(&settings.database_path).to_str().unwrap()).await?; let mut repo = get_repo(&opt.repo.join(&settings.database_path).to_str().unwrap()).await?;
let main_storage_path = opt.repo.join(&settings.default_file_store);
let thumb_storage_path = opt.repo.join(&settings.thumbnail_store); repo.set_main_storage(&settings.default_file_store).await?;
repo.set_main_storage(main_storage_path.to_str().unwrap()) repo.set_thumbnail_storage(&settings.thumbnail_store)
.await?;
repo.set_thumbnail_storage(thumb_storage_path.to_str().unwrap())
.await?; .await?;
Ok((settings, repo)) Ok((settings, repo))
} }
@ -143,11 +147,19 @@ async fn init(opt: Opt, force: bool) -> RepoResult<()> {
} }
log::debug!("Creating repo"); log::debug!("Creating repo");
let repo = get_repo(&db_path.to_str().unwrap()).await?; let repo = get_repo(&db_path.to_str().unwrap()).await?;
let storage_path = opt.repo.join(&settings.default_file_store); let storage_path = opt
.repo
.join(&settings.default_file_store)
.canonicalize()
.unwrap();
log::debug!("Adding storage"); log::debug!("Adding storage");
repo.add_storage(DEFAULT_STORAGE_NAME, storage_path.to_str().unwrap()) repo.add_storage(DEFAULT_STORAGE_NAME, storage_path.to_str().unwrap())
.await?; .await?;
let thumb_storage_path = opt.repo.join(&settings.thumbnail_store); let thumb_storage_path = opt
.repo
.join(&settings.thumbnail_store)
.canonicalize()
.unwrap();
repo.add_storage(THUMBNAIL_STORAGE_NAME, thumb_storage_path.to_str().unwrap()) repo.add_storage(THUMBNAIL_STORAGE_NAME, thumb_storage_path.to_str().unwrap())
.await?; .await?;
let settings_string = settings.to_toml_string()?; let settings_string = settings.to_toml_string()?;

Loading…
Cancel
Save