1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-09 04:22:45 +03:00

Switch to camino's Utf8Path* instead of std::path::Path*

This commit is contained in:
Quentin Gliech
2022-11-18 18:50:11 +01:00
parent c76a1dd2e7
commit a86798d2b3
21 changed files with 99 additions and 74 deletions

View File

@@ -12,9 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::path::PathBuf;
use anyhow::Context;
use camino::Utf8PathBuf;
use clap::Parser;
use mas_config::ConfigurationSection;
@@ -50,7 +49,7 @@ enum Subcommand {
pub struct Options {
/// Path to the configuration file
#[arg(short, long, global = true, action = clap::ArgAction::Append)]
config: Vec<PathBuf>,
config: Vec<Utf8PathBuf>,
#[command(subcommand)]
subcommand: Option<Subcommand>,
@@ -78,7 +77,7 @@ impl Options {
.unwrap_or_else(|_| "config.yaml".to_owned())
// Split the file list on `:`
.split(':')
.map(PathBuf::from)
.map(Utf8PathBuf::from)
.collect()
} else {
self.config.clone()

View File

@@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::path::PathBuf;
use camino::Utf8PathBuf;
use clap::Parser;
use mas_storage::Clock;
use mas_templates::Templates;
@@ -29,7 +28,7 @@ enum Subcommand {
/// Save the builtin templates to a folder
Save {
/// Where the templates should be saved
path: PathBuf,
path: Utf8PathBuf,
/// Overwrite existing template files
#[arg(long)]

View File

@@ -17,8 +17,6 @@
#![warn(clippy::pedantic)]
#![allow(clippy::module_name_repetitions)]
use std::path::PathBuf;
use anyhow::Context;
use clap::Parser;
use mas_config::TelemetryConfig;
@@ -44,7 +42,7 @@ async fn main() -> anyhow::Result<()> {
async fn try_main() -> anyhow::Result<()> {
// Load environment variables from .env files
// We keep the path to log it afterwards
let dotenv_path: Result<Option<PathBuf>, _> = dotenv::dotenv()
let dotenv_path: Result<Option<_>, _> = dotenv::dotenv()
.map(Some)
// Display the error if it is something other than the .env file not existing
.or_else(|e| if e.not_found() { Ok(None) } else { Err(e) });

View File

@@ -60,7 +60,7 @@ where
router.merge(mas_handlers::graphql_router::<AppState, B>(*playground))
}
mas_config::HttpResource::Static { web_root } => {
let handler = mas_static_files::service(web_root);
let handler = mas_static_files::service(web_root.as_deref());
router.nest_service(mas_router::StaticAsset::route(), handler)
}
mas_config::HttpResource::OAuth => {
@@ -91,11 +91,8 @@ where
"root": app_base,
});
let index_service = ViteManifestService::new(
manifest.clone().try_into().unwrap(),
assets_base.into(),
config,
);
let index_service =
ViteManifestService::new(manifest.clone(), assets_base.into(), config);
let static_service = ServeDir::new(assets).append_index_html_on_directories(false);