-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adjust plugin manager to load only if available in the configuration …
…file
- Loading branch information
Showing
10 changed files
with
117 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,10 +13,10 @@ target/ | |
.idea/ | ||
|
||
# data directory | ||
data/ | ||
/data | ||
|
||
# config directory | ||
config/ | ||
/config | ||
|
||
# logs directory | ||
logs/ | ||
/logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* Photos.network · A privacy first photo storage and sharing service for fediverse. | ||
* Copyright (C) 2020 Photos network developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
enum DataAccessError { | ||
NotFound, | ||
#[allow(dead_code)] | ||
TechnicalError, | ||
#[allow(dead_code)] | ||
OtherError, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod DataAccessError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* Photos.network · A privacy first photo storage and sharing service for fediverse. | ||
* Copyright (C) 2020 Photos network developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use std::time::Instant; | ||
|
||
#[derive(Default, Serialize)] | ||
#[cfg_attr(test, derive(Deserialize, Eq, PartialEq, Debug, Copy, Clone, Default))] | ||
pub struct Photo { | ||
pub uuid: &'static str, | ||
pub filename: &'static str, | ||
pub date_added: Instant, | ||
pub date_taken: Option<Instant>, | ||
pub date_modified: Option<Instant>, | ||
pub file_is_missing: bool, | ||
pub owner: &'static str, | ||
} | ||
|
||
impl Photo { | ||
fn new() -> Self { | ||
Photo { | ||
file_is_missing: true | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
use std::fs; | ||
|
||
use serde::Deserialize; | ||
use serde_json::Map; | ||
use tracing::{debug, info}; | ||
|
||
#[derive(Debug, Deserialize, Clone)] | ||
pub struct Configuration { | ||
pub internal_url: String, | ||
pub external_url: String, | ||
pub plugins: Vec<Plugin>, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Clone)] | ||
pub struct Plugin { | ||
pub name: String, | ||
pub config: Option<Map<String, serde_json::Value>> | ||
} | ||
|
||
impl Configuration { | ||
pub fn new(path: &str) -> Option<Self> { | ||
info!("Load configuration file {}", path); | ||
let data = fs::read_to_string(path).expect("Unable to read configuration file!"); | ||
let config: Configuration = serde_json::from_str(&data).expect("Configuration file could not be parsed as JSON!"); | ||
|
||
debug!("internal: {}", config.internal_url); | ||
debug!("external: {}", config.external_url); | ||
debug!("plugins: {:?}", config.plugins); | ||
|
||
Some(config) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters