Skip to content

Commit

Permalink
fix: Implement better filename handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mgattozzi committed Jan 24, 2024
1 parent 2419c46 commit 0de5458
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions influxdb3_write/src/persister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ impl Persister for PersisterImpl {
let item = item?;
catalog_path = match catalog_path {
Some(old_path) => {
let new_catalog_name = item
.location
.filename()
.expect("catalog names are utf-8 encoded");
let Some(new_catalog_name) = item.location.filename() else {
// Skip this iteration as this listed file has no
// filename
catalog_path = Some(old_path);
continue;
};
let old_catalog_name = old_path
.filename()
.expect("catalog names are utf-8 encoded");
// NOTE: this holds so long as CatalogFilePath is used
// from crate::paths
.expect("catalog file paths are guaranteed to have a filename");

// We order catalogs by number starting with u32::MAX and
// then decrease it, therefore if the new catalog file name
Expand All @@ -118,7 +122,11 @@ impl Persister for PersisterImpl {
Some(path) => {
let bytes = self.object_store.get(&path).await?.bytes().await?;
let catalog: InnerCatalog = serde_json::from_slice(&bytes)?;
let file_name = path.filename().expect("catalog names are utf-8 encoded");
let file_name = path
.filename()
// NOTE: this holds so long as CatalogFilePath is used
// from crate::paths
.expect("catalog file paths are guaranteed to have a filename");
let parsed_number = file_name
.trim_end_matches(format!(".{}", crate::paths::CATALOG_FILE_EXTENSION).as_str())
.parse::<u32>()?;
Expand Down

0 comments on commit 0de5458

Please sign in to comment.