This commit is contained in:
AB
2020-06-05 14:31:29 +03:00
parent 28c6fa93b6
commit bf8b2e59b7
4 changed files with 33 additions and 3 deletions

View File

@ -66,14 +66,15 @@ impl HTTP {
.await?
.json::<Vec<RemoteEntry>>()
.await?;
info!("Found {} entries into '{}'", resp.len(), path.display());
debug!("Found {} entries into '{}'", resp.len(), path.display());
Ok(resp)
}
pub async fn read(&self, path: PathBuf, size: usize, offset: usize) -> Result<Vec<u8>, Error> {
debug!("Reading path '{}/{}'", self.server, path.display());
let mut headers = header::HeaderMap::new();
let range = format!("bytes={}-{}", offset, { offset + size });
let range = format!("bytes={}-{}", offset, { offset + size - 1 });
info!("range = {:?}", range);
headers.insert(
header::RANGE,
header::HeaderValue::from_str(range.as_str()).unwrap(),

View File

@ -3,10 +3,12 @@ use std::path::PathBuf;
extern crate log;
use env_logger::Env;
use std::process;
use std::ffi::OsStr;
mod config;
mod filesystem;
mod http;
use itertools::Itertools;
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
@ -22,10 +24,20 @@ async fn main() -> Result<(), std::io::Error> {
error!("The mountpoint must be a directory");
process::exit(0x0004);
}
let options = [
"ro",
"fsname=furumi-http",
// "sync_read",
"auto_unmount",
"allow_other",
].iter().join(",");
let memfs = filesystem::MemFS::new(&cfg);
memfs.fetch_remote(PathBuf::from("/"), 1).await;
polyfuse_tokio::mount(memfs, mountpoint, &[]).await?;
polyfuse_tokio::mount(memfs, mountpoint, &[
"-o".as_ref(),
options.as_ref(),
],).await?;
Ok(())
}