aboutsummaryrefslogtreecommitdiff
path: root/src/controller.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller.rs')
-rw-r--r--src/controller.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/controller.rs b/src/controller.rs
index e63ef97..ba1f2de 100644
--- a/src/controller.rs
+++ b/src/controller.rs
@@ -129,7 +129,7 @@ impl Controller for SoloController {
}
fn before_write(&self, text: &str, ctx: &Context, parts: &mut Parts) -> Result<(), String> {
- if let Some(ext) = ctx.path.extension().and_then(|e| e.to_str()) {
+ if let Some(ext) = ctx.path.extension() {
validate_formats(text, ext)?;
}
Ok(())
@@ -419,7 +419,7 @@ impl Controller for MultiUserController {
let mut ok = false;
self.with_shares_cache(&ctx.repo, ctx.branch.clone(), |shares| {
- if let Some(mode) = shares.find_mode(ctx.path.to_str().unwrap(), username) {
+ if let Some(mode) = shares.find_mode(ctx.path.as_str(), username) {
ok = true;
}
});
@@ -434,9 +434,7 @@ impl Controller for MultiUserController {
let mut ok = false;
self.with_shares_cache(&ctx.repo, ctx.branch.clone(), |shares| {
- if let Some(AccessMode::ReadAndWrite) =
- shares.find_mode(ctx.path.to_str().unwrap(), username)
- {
+ if let Some(AccessMode::ReadAndWrite) = shares.find_mode(ctx.path.as_str(), username) {
ok = true;
}
});
@@ -448,7 +446,7 @@ impl Controller for MultiUserController {
}
fn edit_hint_html(&self, ctx: &Context) -> Option<String> {
- match (ctx.branch.0.as_str(), ctx.path.to_str().unwrap()) {
+ match (ctx.branch.0.as_str(), ctx.path.as_str()) {
(_, ".shares.txt") => {
return Some(include_str!("static/help_shares.txt.html").into());
}
@@ -461,7 +459,7 @@ impl Controller for MultiUserController {
}
fn before_write(&self, text: &str, ctx: &Context, parts: &mut Parts) -> Result<(), String> {
- match (ctx.branch.0.as_str(), ctx.path.to_str().unwrap()) {
+ match (ctx.branch.0.as_str(), ctx.path.as_str()) {
(_, ".shares.txt") => {
parts.extensions.insert(parse_shares_txt(text)?);
}
@@ -471,7 +469,7 @@ impl Controller for MultiUserController {
.insert(toml::from_str::<Identities>(text).map_err(|e| e.to_string())?);
}
_ => {
- if let Some(ext) = ctx.path.extension().and_then(|e| e.to_str()) {
+ if let Some(ext) = ctx.path.extension() {
validate_formats(text, ext)?;
}
}
@@ -480,7 +478,7 @@ impl Controller for MultiUserController {
}
fn after_write(&self, ctx: &Context, parts: &mut Parts) {
- match (ctx.branch.0.as_str(), ctx.path.to_str().unwrap()) {
+ match (ctx.branch.0.as_str(), ctx.path.as_str()) {
(_, ".shares.txt") => {
self.shares_cache
.write()
@@ -499,7 +497,7 @@ impl Controller for MultiUserController {
if own_username != ctx.branch.0 {
return None;
}
- let path = ctx.path.to_str().unwrap();
+ let path = ctx.path.as_str();
let mut result = None;
self.with_shares_cache(&ctx.repo, ctx.branch.clone(), |shares| {
let mut users = HashMap::new();