mirror of
https://github.com/house-of-vanity/furumi.git
synced 2025-07-06 21:24:08 +00:00
It works
This commit is contained in:
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -184,6 +184,12 @@ version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.23"
|
||||
@ -256,6 +262,7 @@ dependencies = [
|
||||
"env_logger",
|
||||
"futures",
|
||||
"futures-intrusive",
|
||||
"itertools",
|
||||
"libc",
|
||||
"log",
|
||||
"percent-encoding",
|
||||
@ -525,6 +532,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.5"
|
||||
|
@ -33,6 +33,7 @@ size_format = "1.0"
|
||||
base64 = "0.12"
|
||||
ctrlc = "3.1"
|
||||
config = "0.9"
|
||||
itertools = "*"
|
||||
|
||||
[dev-dependencies.tokio]
|
||||
version = "0.2"
|
||||
|
@ -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(),
|
||||
|
14
src/main.rs
14
src/main.rs
@ -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(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user