Skip to content

Commit 0ae45a7

Browse files
committed
coderabbit suggestions
1 parent ff17445 commit 0ae45a7

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

src/handlers/http/logstream.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,19 @@ pub async fn get_stream_hot_tier(stream_name: Path<String>) -> Result<impl Respo
445445
};
446446
let meta = hot_tier_manager.get_hot_tier(&stream_name).await?;
447447

448+
let mut stream_metadata: ObjectStoreFormat = serde_json::from_slice(
449+
&PARSEABLE
450+
.metastore
451+
.get_stream_json(&stream_name, false)
452+
.await?,
453+
)?;
454+
stream_metadata.hot_tier_enabled = false;
455+
456+
PARSEABLE
457+
.metastore
458+
.put_stream_json(&stream_metadata, &stream_name)
459+
.await?;
460+
448461
Ok((web::Json(meta), StatusCode::OK))
449462
}
450463

src/storage/localfs.rs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,29 @@ impl ObjectStorage for LocalFS {
139139
}
140140
async fn get_object(&self, path: &RelativePath) -> Result<Bytes, ObjectStorageError> {
141141
let time = Instant::now();
142-
let file_path = if path.to_string().contains(&self.root.to_str().unwrap()[1..]) {
143-
#[cfg(windows)]
144-
{
145-
path.to_path("")
146-
}
147-
#[cfg(not(windows))]
148-
{
142+
143+
let file_path;
144+
145+
// this is for the `get_manifest()` function because inside a snapshot, we store the absolute path (without `/`) on linux based OS
146+
// `home/user/.../manifest.json`
147+
// on windows, the path is stored with the drive letter
148+
// `D:\\parseable\\data..\\manifest.json`
149+
// thus, we need to check if the root of localfs is already present in the path
150+
#[cfg(windows)]
151+
{
152+
// in windows the absolute path (self.root) doesn't matter because we store the complete path
153+
file_path = path.to_path("");
154+
}
155+
#[cfg(not(windows))]
156+
{
157+
// absolute path (self.root) will always start with `/`
158+
let root_str = self.root.to_str().unwrap();
159+
file_path = if path.to_string().contains(&root_str[1..]) && root_str.len() > 1 {
149160
path.to_path("/")
150-
}
151-
} else {
152-
self.path_in_root(path)
153-
};
161+
} else {
162+
self.path_in_root(path)
163+
};
164+
}
154165

155166
let res: Result<Bytes, ObjectStorageError> = match fs::read(file_path).await {
156167
Ok(x) => Ok(x.into()),

src/storage/object_storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ pub async fn commit_schema_to_storage(
989989
schema,
990990
serde_json::from_slice::<Schema>(&stream_schema)?,
991991
])
992-
.unwrap();
992+
.map_err(|e| ObjectStorageError::Custom(e.to_string()))?;
993993

994994
PARSEABLE
995995
.metastore

0 commit comments

Comments
 (0)