Browse Source
fix: round 5 Go parity — range clamping, ETag on 201, image decompress, tier maintenance
fix: round 5 Go parity — range clamping, ETag on 201, image decompress, tier maintenance
- Range requests: clamp end to file size instead of returning 416 (matches Go) - Suffix ranges larger than file size: clamp instead of skipping (matches Go) - Set ETag response header on 201 Created write responses (matches Go SetEtag) - Always decompress before image resize/crop even when client accepts gzip - VolumeTierMoveDatFromRemote: don't check maintenance mode (Go doesn't) - Fix stale integration test: stats routes are now exposed on admin routerrust-volume-server
7 changed files with 128 additions and 21 deletions
-
1seaweed-volume/src/lib.rs
-
2seaweed-volume/src/main.rs
-
4seaweed-volume/src/server/grpc_server.rs
-
64seaweed-volume/src/server/handlers.rs
-
4seaweed-volume/src/server/volume_server.rs
-
70seaweed-volume/src/version.rs
-
4seaweed-volume/tests/http_integration.rs
@ -0,0 +1,70 @@ |
|||||
|
//! Version helpers aligned with Go's util/version package.
|
||||
|
|
||||
|
use std::sync::OnceLock;
|
||||
|
|
||||
|
const SIZE_LIMIT: &str = "30GB"; // Go default build (!5BytesOffset)
|
||||
|
|
||||
|
pub fn size_limit() -> &'static str {
|
||||
|
SIZE_LIMIT
|
||||
|
}
|
||||
|
|
||||
|
pub fn commit() -> &'static str {
|
||||
|
option_env!("SEAWEEDFS_COMMIT")
|
||||
|
.or(option_env!("GIT_COMMIT"))
|
||||
|
.or(option_env!("GIT_SHA"))
|
||||
|
.unwrap_or("")
|
||||
|
}
|
||||
|
|
||||
|
pub fn version_number() -> &'static str {
|
||||
|
static VERSION_NUMBER: OnceLock<String> = OnceLock::new();
|
||||
|
VERSION_NUMBER
|
||||
|
.get_or_init(|| parse_go_version_number().unwrap_or_else(|| env!("CARGO_PKG_VERSION").to_string()))
|
||||
|
.as_str()
|
||||
|
}
|
||||
|
|
||||
|
pub fn version() -> &'static str {
|
||||
|
static VERSION: OnceLock<String> = OnceLock::new();
|
||||
|
VERSION
|
||||
|
.get_or_init(|| format!("{} {}", size_limit(), version_number()))
|
||||
|
.as_str()
|
||||
|
}
|
||||
|
|
||||
|
pub fn full_version() -> &'static str {
|
||||
|
static FULL: OnceLock<String> = OnceLock::new();
|
||||
|
FULL.get_or_init(|| format!("{} {}", version(), commit())).as_str()
|
||||
|
}
|
||||
|
|
||||
|
pub fn server_header() -> &'static str {
|
||||
|
static HEADER: OnceLock<String> = OnceLock::new();
|
||||
|
HEADER
|
||||
|
.get_or_init(|| format!("SeaweedFS Volume {}", version()))
|
||||
|
.as_str()
|
||||
|
}
|
||||
|
|
||||
|
fn parse_go_version_number() -> Option<String> {
|
||||
|
let src = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../weed/util/version/constants.go"));
|
||||
|
let mut major: Option<u32> = None;
|
||||
|
let mut minor: Option<u32> = None;
|
||||
|
for line in src.lines() {
|
||||
|
let l = line.trim();
|
||||
|
if l.starts_with("MAJOR_VERSION") {
|
||||
|
major = parse_int32_line(l);
|
||||
|
} else if l.starts_with("MINOR_VERSION") {
|
||||
|
minor = parse_int32_line(l);
|
||||
|
}
|
||||
|
if major.is_some() && minor.is_some() {
|
||||
|
break;
|
||||
|
}
|
||||
|
}
|
||||
|
match (major, minor) {
|
||||
|
(Some(maj), Some(min)) => Some(format!("{}.{}", maj, format!("{:02}", min))),
|
||||
|
_ => None,
|
||||
|
}
|
||||
|
}
|
||||
|
|
||||
|
fn parse_int32_line(line: &str) -> Option<u32> {
|
||||
|
let start = line.find("int32(")? + "int32(".len();
|
||||
|
let rest = &line[start..];
|
||||
|
let end = rest.find(')')?;
|
||||
|
rest[..end].trim().parse::<u32>().ok()
|
||||
|
}
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue