Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #25

Merged
merged 8 commits into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ jobs:

- name: Check daemon
working-directory: mediarepo-daemon
run: cargo check --no-default-features
run: cargo check

- name: Lint api
working-directory: mediarepo-api
run: cargo clippy -- -D warnings

- name: Lint daemon
working-directory: mediarepo-daemon
run: cargo clippy -- -D warnings

- name: Install UI dependencies
working-directory: mediarepo-ui
Expand All @@ -47,4 +55,4 @@ jobs:

- name: Lint ui frontend
working-directory: mediarepo-ui
run: yarn lint
run: yarn lint
2 changes: 1 addition & 1 deletion mediarepo-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mediarepo-api"
version = "0.32.0"
version = "0.32.1"
edition = "2018"
license = "gpl-3"

Expand Down
6 changes: 6 additions & 0 deletions mediarepo-api/src/client_api/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ impl JobApi {

Ok(())
}

/// Checks if a particular job is already running
#[tracing::instrument(level = "debug", skip(self))]
pub async fn is_job_running(&self, job_type: JobType) -> ApiResult<bool> {
self.emit_and_get("is_job_running", job_type, None).await
}
}
8 changes: 8 additions & 0 deletions mediarepo-api/src/tauri_plugin/commands/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ pub async fn run_job(api_state: ApiAccess<'_>, job_type: JobType, sync: bool) ->

Ok(())
}

#[tauri::command]
pub async fn is_job_running(api_state: ApiAccess<'_>, job_type: JobType) -> PluginResult<bool> {
let api = api_state.api().await?;
let running = api.job.is_job_running(job_type).await?;

Ok(running)
}
3 changes: 2 additions & 1 deletion mediarepo-api/src/tauri_plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ impl<R: Runtime> MediarepoPlugin<R> {
get_file_tag_map,
all_sorting_presets,
add_sorting_preset,
delete_sorting_preset
delete_sorting_preset,
is_job_running
]),
}
}
Expand Down
101 changes: 100 additions & 1 deletion mediarepo-daemon/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion mediarepo-daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default-members = ["mediarepo-core", "mediarepo-database", "mediarepo-logic", "m

[package]
name = "mediarepo-daemon"
version = "1.0.3"
version = "1.0.4"
edition = "2018"
license = "gpl-3"
repository = "https://github.com/Trivernis/mediarepo-daemon"
Expand All @@ -30,6 +30,7 @@ log = "0.4.16"
opentelemetry = { version = "0.17.0", features = ["rt-tokio"] }
opentelemetry-jaeger = { version = "0.16.0", features = ["rt-tokio"] }
tracing-opentelemetry = "0.17.2"
human-panic = "1.0.3"

[dependencies.mediarepo-core]
path = "./mediarepo-core"
Expand Down
2 changes: 1 addition & 1 deletion mediarepo-daemon/mediarepo-core/src/fs/thumbnail_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl ThumbnailStore {
let name = file_name.to_string_lossy();

let (height, width) = name
.split_once("-")
.split_once('-')
.and_then(|(height, width)| {
Some((height.parse::<u32>().ok()?, width.parse::<u32>().ok()?))
})
Expand Down
1 change: 1 addition & 0 deletions mediarepo-daemon/mediarepo-core/src/settings/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub enum LogLevel {
Trace,
}

#[allow(clippy::from_over_into)]
impl Into<Option<Level>> for LogLevel {
fn into(self) -> Option<Level> {
match self {
Expand Down
8 changes: 4 additions & 4 deletions mediarepo-daemon/mediarepo-core/src/settings/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fs;
use std::path::PathBuf;
use std::path::{Path, PathBuf};

use config::{Config, FileFormat};
use serde::{Deserialize, Serialize};
Expand All @@ -24,7 +24,7 @@ pub struct Settings {
}

impl Settings {
pub fn read(root: &PathBuf) -> RepoResult<Self> {
pub fn read(root: &Path) -> RepoResult<Self> {
let settings = Config::builder()
.add_source(config::File::from_str(
&*Settings::default().to_toml_string()?,
Expand All @@ -44,7 +44,7 @@ impl Settings {
settings_main.server.tcp.enabled = true;
settings_main.server.tcp.port = PortSetting::Range(settings_v1.port_range);
settings_main.server.tcp.listen_address = settings_v1.listen_address;
settings_main.paths.thumbnail_directory = settings_v1.thumbnail_store.into();
settings_main.paths.thumbnail_directory = settings_v1.thumbnail_store;
settings_main.paths.database_directory = PathBuf::from(settings_v1.database_path)
.parent()
.map(|p| p.to_string_lossy().to_string())
Expand All @@ -69,7 +69,7 @@ impl Settings {
Ok(string)
}

pub fn save(&self, root: &PathBuf) -> RepoResult<()> {
pub fn save(&self, root: &Path) -> RepoResult<()> {
let string = toml::to_string_pretty(&self)?;
fs::write(root.join("repo.toml"), string.into_bytes())?;

Expand Down
12 changes: 6 additions & 6 deletions mediarepo-daemon/mediarepo-core/src/settings/paths.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::path::{Path, PathBuf};

use serde::{Deserialize, Serialize};

Expand All @@ -21,27 +21,27 @@ impl Default for PathSettings {

impl PathSettings {
#[inline]
pub fn database_dir(&self, root: &PathBuf) -> PathBuf {
pub fn database_dir(&self, root: &Path) -> PathBuf {
root.join(&self.database_directory)
}

#[inline]
pub fn files_dir(&self, root: &PathBuf) -> PathBuf {
pub fn files_dir(&self, root: &Path) -> PathBuf {
root.join(&self.files_directory)
}

#[inline]
pub fn thumbs_dir(&self, root: &PathBuf) -> PathBuf {
pub fn thumbs_dir(&self, root: &Path) -> PathBuf {
root.join(&self.thumbnail_directory)
}

#[inline]
pub fn db_file_path(&self, root: &PathBuf) -> PathBuf {
pub fn db_file_path(&self, root: &Path) -> PathBuf {
self.database_dir(root).join("repo.db")
}

#[inline]
pub fn frontend_state_file_path(&self, root: &PathBuf) -> PathBuf {
pub fn frontend_state_file_path(&self, root: &Path) -> PathBuf {
self.database_dir(root).join("frontend-state.json")
}
}
8 changes: 7 additions & 1 deletion mediarepo-daemon/mediarepo-core/src/tracing_layer_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ use tracing_subscriber::Layer;

pub struct DynLayerList<S>(Vec<Box<dyn Layer<S> + Send + Sync + 'static>>);

impl<S> Default for DynLayerList<S> {
fn default() -> Self {
Self(Vec::new())
}
}

impl<S> DynLayerList<S> {
pub fn new() -> Self {
Self(Vec::new())
Self::default()
}

pub fn iter(&self) -> Iter<'_, Box<dyn Layer<S> + Send + Sync>> {
Expand Down
7 changes: 0 additions & 7 deletions mediarepo-daemon/mediarepo-core/src/traits.rs

This file was deleted.

Loading