Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
419049068a
|
@@ -3,11 +3,12 @@ name: default
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build
|
- name: build
|
||||||
image: rust:1.41.0-buster
|
image: rust:1.37.0-buster
|
||||||
commands:
|
commands:
|
||||||
- apt update && apt install git clang make pkg-config nettle-dev libssl-dev capnproto libsqlite3-dev -y
|
- apt update && apt install git clang make pkg-config nettle-dev libssl-dev capnproto libsqlite3-dev -y
|
||||||
- cargo test
|
- cargo test
|
||||||
- cargo install --path . --root .
|
- rustup target add x86_64-unknown-linux-musl
|
||||||
|
- cargo build --release --target x86_64-unknown-linux-musl
|
||||||
- name: dockerize
|
- name: dockerize
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
|
2097
Cargo.lock
generated
2097
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
19
Cargo.toml
19
Cargo.toml
@@ -1,23 +1,22 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "brownpaper"
|
name = "brownpaper"
|
||||||
version = "0.4.0"
|
version = "0.1.0"
|
||||||
authors = ["shimun <shimun@shimun.net>"]
|
authors = ["shim_ <shimun@shimun.net>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
opt-level = 'z'
|
||||||
|
panic = 'abort'
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
snap = "0.1"
|
snap = "0.1"
|
||||||
|
|
||||||
rustc-serialize = "0.3.19"
|
rustc-serialize = "0.3.19"
|
||||||
|
|
||||||
iron = "0.6.0"
|
|
||||||
|
|
||||||
rand = "0.4.2"
|
rand = "0.4.2"
|
||||||
|
|
||||||
byteorder = "1.3.2"
|
byteorder = "1.3.2"
|
||||||
chrono = "0.4.9"
|
chrono = "0.4.9"
|
||||||
sequoia-openpgp = "0.12.0"
|
sequoia-openpgp = "0.9.0"
|
||||||
lazy_static = "1.4.0"
|
|
||||||
c2-chacha = "0.2.2"
|
c2-chacha = "0.2.2"
|
||||||
sha2 = "0.8.0"
|
sha2 = "0.8.0"
|
||||||
hex = "0.3.2"
|
hex = "0.3.2"
|
||||||
|
tower-web = "0.3.7"
|
||||||
|
tokio = "0.1.22"
|
||||||
|
14
Dockerfile
14
Dockerfile
@@ -1,21 +1,9 @@
|
|||||||
FROM rust:1.41.0 as builder
|
|
||||||
|
|
||||||
COPY . /bp
|
|
||||||
|
|
||||||
RUN apt update
|
|
||||||
|
|
||||||
RUN apt install clang nettle-dev -y
|
|
||||||
|
|
||||||
RUN cargo install --path /bp --root /usr
|
|
||||||
|
|
||||||
FROM debian:buster-slim
|
FROM debian:buster-slim
|
||||||
|
|
||||||
VOLUME /snips
|
VOLUME /snips
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
COPY --from=builder /usr/bin/brownpaper /bin/
|
COPY target/release/brownpaper /bin/
|
||||||
|
|
||||||
WORKDIR /
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/bin/brownpaper" ]
|
ENTRYPOINT [ "/bin/brownpaper" ]
|
||||||
|
9
bp.sh
9
bp.sh
@@ -1,9 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
BP_ENDPOINT=${BROWNPAPER_ENDPOINT:-https://shimun.net/bp}
|
|
||||||
CURL_ARGS="--write-out %{url_effective}\\n --silent -o /dev/null"
|
|
||||||
GPG_ARGS="$([ ! -z "$BROWNPAPER_KEY" ] && echo "--local-user $BROWNPAPER_KEY")"
|
|
||||||
if [ ! -z "$1" ]; then
|
|
||||||
printf "$1" | gpg --sign -a $GPG_ARGS | curl -s --data @- -X POST $BP_ENDPOINT/new -Ls $CURL_ARGS
|
|
||||||
else
|
|
||||||
gpg --sign -a $GPG_ARGS | curl -s --data @- -X POST $BP_ENDPOINT/new -Ls $CURL_ARGS
|
|
||||||
fi
|
|
25
default.nix
25
default.nix
@@ -1,25 +0,0 @@
|
|||||||
{ pkgs ? import <nixpkgs> { }
|
|
||||||
, callPackage ? pkgs.callPackage
|
|
||||||
, stdenv ? pkgs.stdenv
|
|
||||||
, fetchgit ? pkgs.fetchgit
|
|
||||||
, name ? "brownpaper"
|
|
||||||
, src ? (builtins.filterSource (path: type: baseNameOf path != "target") ./.)
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
crate2nix_tools = import "${fetchgit { url = "https://github.com/kolloch/crate2nix.git"; rev = "adecff03c53b87255b3299f5a5787327342a69b2"; sha256 = "0l10yqa3gq73fc4xc977vb9zk5jlp70xiz5qd9c1vq873yqk1c7g"; }}/tools.nix" { inherit pkgs; };
|
|
||||||
overrides = pkgs.defaultCrateOverrides // rec {
|
|
||||||
nettle-sys = attrs: with pkgs; {
|
|
||||||
propagatedBuildInputs = [ clang nettle pkg-config ];
|
|
||||||
LIBCLANG_PATH = "${clang.cc.lib}/lib";
|
|
||||||
};
|
|
||||||
sequoia-openpgp = attrs: with pkgs; {
|
|
||||||
nativeBuildInputs = [ clang gmp pkg-config ];
|
|
||||||
LIBCLANG_PATH = "${clang.cc.lib}/lib";
|
|
||||||
};
|
|
||||||
brownpaper = sequoia-openpgp; # requires gmp as well
|
|
||||||
};
|
|
||||||
client = pkgs.writeShellScriptBin "brownpaper" ''
|
|
||||||
PATH=${pkgs.bash}/bin/:${pkgs.gnupg}/bin/:${pkgs.curl}/bin/:$PATH ${./bp.sh} "$@"
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{ server = callPackage (crate2nix_tools.generatedCargoNix { inherit name src; }) { inherit pkgs; }; inherit client; }
|
|
@@ -1,12 +1,11 @@
|
|||||||
use c2_chacha::stream_cipher::{NewStreamCipher, SyncStreamCipher, SyncStreamCipherSeek};
|
use c2_chacha::stream_cipher::{NewStreamCipher, SyncStreamCipher};
|
||||||
use c2_chacha::{ChaCha12, ChaCha20};
|
use c2_chacha::ChaCha20;
|
||||||
use std::convert::TryInto;
|
|
||||||
use std::io::{Read, Result, Write};
|
use std::io::{Read, Result, Write};
|
||||||
|
|
||||||
pub struct ChaChaReader<'a>(ChaCha20, &'a mut Read);
|
pub struct ChaChaReader<'a>(ChaCha20, &'a mut dyn Read);
|
||||||
|
|
||||||
impl<'a> ChaChaReader<'a> {
|
impl<'a> ChaChaReader<'a> {
|
||||||
pub fn new(key: &[u8], nonce: &[u8], source: &'a mut Read) -> ChaChaReader<'a> {
|
pub fn new(key: &[u8], nonce: &[u8], source: &'a mut dyn Read) -> ChaChaReader<'a> {
|
||||||
ChaChaReader(ChaCha20::new_var(key, nonce).unwrap(), source)
|
ChaChaReader(ChaCha20::new_var(key, nonce).unwrap(), source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,10 +18,10 @@ impl<'a> Read for ChaChaReader<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ChaChaWriter<'a>(ChaCha20, &'a mut Write);
|
pub struct ChaChaWriter<'a>(ChaCha20, &'a mut dyn Write);
|
||||||
|
|
||||||
impl<'a> ChaChaWriter<'a> {
|
impl<'a> ChaChaWriter<'a> {
|
||||||
pub fn new(key: &[u8], nonce: &[u8], sink: &'a mut Write) -> ChaChaWriter<'a> {
|
pub fn new(key: &[u8], nonce: &[u8], sink: &'a mut dyn Write) -> ChaChaWriter<'a> {
|
||||||
ChaChaWriter(ChaCha20::new_var(key, nonce).unwrap(), sink)
|
ChaChaWriter(ChaCha20::new_var(key, nonce).unwrap(), sink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
135
src/main.rs
135
src/main.rs
@@ -1,140 +1,13 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
extern crate tower_web;
|
||||||
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
extern crate chrono;
|
|
||||||
extern crate iron;
|
|
||||||
extern crate rand;
|
|
||||||
extern crate sequoia_openpgp as openpgp;
|
extern crate sequoia_openpgp as openpgp;
|
||||||
extern crate snap;
|
|
||||||
|
|
||||||
mod chacha_io;
|
mod chacha_io;
|
||||||
mod pgp;
|
mod pgp;
|
||||||
|
mod server;
|
||||||
mod snippet;
|
mod snippet;
|
||||||
|
|
||||||
use crate::pgp::KnownKeys;
|
|
||||||
use crate::snippet::*;
|
|
||||||
|
|
||||||
use iron::method::Method;
|
|
||||||
use iron::modifiers::Redirect;
|
|
||||||
use iron::prelude::*;
|
|
||||||
use iron::url::Url;
|
|
||||||
|
|
||||||
use iron::mime::Mime;
|
|
||||||
use sha2::Digest;
|
|
||||||
|
|
||||||
use std::env::{self, args};
|
|
||||||
use std::io;
|
|
||||||
use std::io::prelude::*;
|
|
||||||
use std::iter::Iterator;
|
|
||||||
use std::net::SocketAddr;
|
|
||||||
use std::path::Path;
|
|
||||||
use std::sync::Arc;
|
|
||||||
use std::sync::Mutex;
|
|
||||||
|
|
||||||
const STORAGE_DIR: &str = "./snips";
|
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
static ref KNOWN_KEYS: Arc<Mutex<KnownKeys>> = Arc::new(Mutex::new(
|
|
||||||
KnownKeys::load_dir([STORAGE_DIR, "keys"].join("/")).expect("Failed to load pubkeys")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
||||||
|
|
||||||
fn handle(req: &mut Request) -> IronResult<Response> {
|
|
||||||
println!("{}", req.url);
|
|
||||||
let storage = SnippetStorage::new(&Path::new(&STORAGE_DIR));
|
|
||||||
let segments: Vec<&str> = req.url.path();
|
|
||||||
match (&req.method, segments.first()) {
|
|
||||||
(Method::Get, Some(&"version")) => Ok(Response::with((iron::status::Ok, VERSION))),
|
|
||||||
(Method::Post, Some(path)) => {
|
|
||||||
if path == &"new" {
|
|
||||||
let snip = {
|
|
||||||
let pgp_text: String = {
|
|
||||||
let bytes = ((&mut req.body).bytes().take(1024 * 512).collect::<Result<
|
|
||||||
Vec<u8>,
|
|
||||||
io::Error,
|
|
||||||
>>(
|
|
||||||
))
|
|
||||||
.map_err(|err| IronError::new(err, ""))?;
|
|
||||||
String::from_utf8(bytes)
|
|
||||||
.map_err(|err| IronError::new(err, "Invalid utf8"))?
|
|
||||||
};
|
|
||||||
let b_text = KNOWN_KEYS
|
|
||||||
.lock()
|
|
||||||
.unwrap() //.map_err(|_| IronError::new(std::error::Error::from("Mutex Err"), "PGP Context unavailable"))?
|
|
||||||
.verify(pgp_text.as_bytes())
|
|
||||||
.map_err(|err| IronError::new(err, "Untrusted signature"))?;
|
|
||||||
let text = String::from_utf8(b_text).unwrap();
|
|
||||||
Snippet::random(&storage).write(&*text).map_err(|err| {
|
|
||||||
let msg = format!("Failed to save snippet: {:?}", &err);
|
|
||||||
IronError::new(err, msg)
|
|
||||||
})
|
|
||||||
};
|
|
||||||
snip.map(|snip| {
|
|
||||||
let mut snip_url: Url = req.url.clone().into();
|
|
||||||
snip_url.set_path(&*("/".to_string() + &*snip.id));
|
|
||||||
Response::with((
|
|
||||||
iron::status::TemporaryRedirect,
|
|
||||||
Redirect(iron::Url::from_generic_url(snip_url).unwrap()),
|
|
||||||
))
|
|
||||||
/*Response::with((
|
|
||||||
iron::status::Ok,
|
|
||||||
format!(
|
|
||||||
"<meta http-equiv=\"refresh\" content=\"0; url={}/\" />",
|
|
||||||
snip_url
|
|
||||||
),
|
|
||||||
))*/
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
Ok(Response::with((
|
|
||||||
iron::status::BadRequest,
|
|
||||||
"Post to /new or die",
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(Method::Get, Some(path)) => {
|
|
||||||
let (id, mime) = {
|
|
||||||
let mut parts = path.split(".");
|
|
||||||
(
|
|
||||||
parts.next().unwrap().to_string(),
|
|
||||||
Some(parts.collect::<Vec<_>>().join("/"))
|
|
||||||
.filter(|s| s.len() > 0)
|
|
||||||
.and_then(|format| format.parse::<Mime>().ok()),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
let mime = mime.unwrap_or("text/plain".parse().unwrap());
|
|
||||||
let att = storage.open(&id).map(|snip| snip.contents()).map(|res| {
|
|
||||||
Response::with(
|
|
||||||
match res.map(|text| (iron::status::Ok, text)).map_err(|err| {
|
|
||||||
let msg = format!("Failed to load snippet: {:?}", &err);
|
|
||||||
msg
|
|
||||||
}) {
|
|
||||||
Ok(res) => res,
|
|
||||||
Err(e) => (iron::status::InternalServerError, e),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.set(mime)
|
|
||||||
});
|
|
||||||
Ok(att.unwrap_or(Response::with((iron::status::NotFound, "Not here sry"))))
|
|
||||||
}
|
|
||||||
(Method::Get, _) => Ok(Response::with((iron::status::NotFound, "Wrong path pal"))),
|
|
||||||
_ => Ok(Response::with((iron::status::BadRequest, "Give or take"))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let chain = Chain::new(handle);
|
server::run();
|
||||||
println!("Starting brownpaper: {}", STORAGE_DIR);
|
|
||||||
Iron::new(chain).http(
|
|
||||||
args()
|
|
||||||
.skip(1)
|
|
||||||
.next()
|
|
||||||
.map(|ip| {
|
|
||||||
ip.parse::<SocketAddr>()
|
|
||||||
.expect("can't parse socket address")
|
|
||||||
})
|
|
||||||
.unwrap_or("0.0.0.0:3000".parse::<SocketAddr>().unwrap())
|
|
||||||
.to_string()
|
|
||||||
.as_str(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
26
src/pgp.rs
26
src/pgp.rs
@@ -1,12 +1,13 @@
|
|||||||
|
use crate::snippet::*;
|
||||||
use openpgp::parse::stream::*;
|
use openpgp::parse::stream::*;
|
||||||
use openpgp::parse::Parse;
|
use openpgp::parse::Parse;
|
||||||
use openpgp::*;
|
use openpgp::*;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::File;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct KnownKeys {
|
pub struct KnownKeys {
|
||||||
keys: Vec<openpgp::TPK>,
|
keys: Vec<openpgp::TPK>,
|
||||||
}
|
}
|
||||||
@@ -40,29 +41,6 @@ impl KnownKeys {
|
|||||||
let mut v = Verifier::<&KnownKeys>::from_reader(r, helper, None).map_err(|e| {
|
let mut v = Verifier::<&KnownKeys>::from_reader(r, helper, None).map_err(|e| {
|
||||||
io::Error::new(io::ErrorKind::InvalidData, "Failed to verify signature")
|
io::Error::new(io::ErrorKind::InvalidData, "Failed to verify signature")
|
||||||
})?;
|
})?;
|
||||||
let mut buf = [0u8; 512];
|
|
||||||
let bp = "brownpaper".as_bytes();
|
|
||||||
loop {
|
|
||||||
match v.read(&mut buf)? {
|
|
||||||
0 => break,
|
|
||||||
read => {
|
|
||||||
// first buffer read
|
|
||||||
if content.len() == 0 {
|
|
||||||
if !(buf.len() > bp.len() && bp == &buf[0..bp.len()]) {
|
|
||||||
return Err(io::Error::new(
|
|
||||||
io::ErrorKind::InvalidData,
|
|
||||||
"Failed to verify signature(prefix)",
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
// remove prefix
|
|
||||||
content.extend_from_slice(&buf[bp.len()..read])
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
content.extend_from_slice(&buf[0..read]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if v.read_to_end(&mut content).is_err() {
|
if v.read_to_end(&mut content).is_err() {
|
||||||
return Err(io::Error::new(
|
return Err(io::Error::new(
|
||||||
io::ErrorKind::InvalidData,
|
io::ErrorKind::InvalidData,
|
||||||
|
53
src/server.rs
Normal file
53
src/server.rs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
use crate::pgp::KnownKeys;
|
||||||
|
use crate::snippet::*;
|
||||||
|
use std::path::Path;
|
||||||
|
use std::sync::Mutex;
|
||||||
|
use tokio::prelude::*;
|
||||||
|
use tower_web::ServiceBuilder;
|
||||||
|
use tower_web::{derive_resource_impl, impl_web};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Brownpaper {
|
||||||
|
storage: SnippetStorage,
|
||||||
|
known_keys: Mutex<KnownKeys>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_web! {
|
||||||
|
impl Brownpaper {
|
||||||
|
#[get("/")]
|
||||||
|
async fn root(&self) -> &'static str {
|
||||||
|
"Post /new, Get /<id>"
|
||||||
|
}
|
||||||
|
|
||||||
|
#[post("/new")]
|
||||||
|
async fn new(&self) -> Result<> {}
|
||||||
|
|
||||||
|
#[get("/:id")]
|
||||||
|
async fn snipptet(&self, id: String) -> Result<> {}
|
||||||
|
|
||||||
|
#[get("/file/:file_id")]
|
||||||
|
async fn snipptet_file(&self, file_id: String) -> Result<> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
const STORAGE_DIR: &str = "/snips";
|
||||||
|
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
const STORAGE_DIR: &str = "/tmp";
|
||||||
|
|
||||||
|
pub fn run() {
|
||||||
|
let addr = "0.0.0.0:3000".parse().expect("Invalid address");
|
||||||
|
println!("Listening on http://{}", addr);
|
||||||
|
|
||||||
|
ServiceBuilder::new()
|
||||||
|
.resource(Brownpaper {
|
||||||
|
storage: SnippetStorage::new(Path::new(STORAGE_DIR)),
|
||||||
|
known_keys: Mutex::new(
|
||||||
|
KnownKeys::load_dir([STORAGE_DIR, "keys"].join("/"))
|
||||||
|
.expect("Failed to load PGP Keys"),
|
||||||
|
),
|
||||||
|
})
|
||||||
|
.run(&addr)
|
||||||
|
.unwrap();
|
||||||
|
}
|
@@ -1,31 +1,31 @@
|
|||||||
use crate::chacha_io::{ChaChaReader, ChaChaWriter};
|
use crate::chacha_io::{ChaChaReader, ChaChaWriter};
|
||||||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use chrono::*;
|
use chrono::*;
|
||||||
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::iter::Iterator;
|
use std::iter::Iterator;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Snippet<'a> {
|
pub struct Snippet<'a> {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub storage: &'a SnippetStorage<'a>,
|
pub storage: &'a SnippetStorage,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct SnippetMeta {
|
pub struct SnippetMeta {
|
||||||
created: DateTime<Utc>,
|
created: DateTime<Utc>,
|
||||||
compression: Option<String>,
|
compression: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SnippetStorage<'a> {
|
#[derive(Debug)]
|
||||||
directory: &'a Path,
|
pub struct SnippetStorage {
|
||||||
|
directory: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Snippet<'a> {
|
impl<'a> Snippet<'a> {
|
||||||
@@ -80,7 +80,7 @@ impl<'a> Snippet<'a> {
|
|||||||
hdl.read_exact(&mut comp)?;
|
hdl.read_exact(&mut comp)?;
|
||||||
let comp = String::from_utf8(comp).unwrap();
|
let comp = String::from_utf8(comp).unwrap();
|
||||||
Ok(SnippetMeta {
|
Ok(SnippetMeta {
|
||||||
created: Utc.timestamp(timestamp, 0),
|
created: Utc.timestamp_millis(timestamp),
|
||||||
compression: Some(comp).filter(|_| comp_len > 0),
|
compression: Some(comp).filter(|_| comp_len > 0),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -128,10 +128,10 @@ impl<'a> Snippet<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SnippetStorage<'a> {
|
impl SnippetStorage {
|
||||||
pub fn new(directory: &'a Path) -> SnippetStorage<'a> {
|
pub fn new(directory: impl Into<PathBuf>) -> SnippetStorage {
|
||||||
SnippetStorage {
|
SnippetStorage {
|
||||||
directory: directory,
|
directory: directory.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn file_id(id: &str) -> String {
|
pub fn file_id(id: &str) -> String {
|
||||||
|
Reference in New Issue
Block a user