Skip to content

Commit 4b5d9bf

Browse files
Fix issue #5800: Handle missing files in list_with_delimiter (#5803)
1 parent 7342d36 commit 4b5d9bf

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

object_store/src/local.rs

+18-9
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ impl ObjectStore for LocalFileSystem {
504504

505505
match config.filesystem_to_path(entry.path()) {
506506
Ok(path) => match is_valid_file_path(&path) {
507-
true => Some(convert_entry(entry, path)),
507+
true => convert_entry(entry, path).transpose(),
508508
false => None,
509509
},
510510
Err(e) => Some(Err(e)),
@@ -581,8 +581,8 @@ impl ObjectStore for LocalFileSystem {
581581

582582
if is_directory {
583583
common_prefixes.insert(prefix.child(common_prefix));
584-
} else {
585-
objects.push(convert_entry(entry, entry_location)?);
584+
} else if let Some(metadata) = convert_entry(entry, entry_location)? {
585+
objects.push(metadata);
586586
}
587587
}
588588
}
@@ -894,12 +894,21 @@ fn open_file(path: &PathBuf) -> Result<(File, Metadata)> {
894894
Ok(ret)
895895
}
896896

897-
fn convert_entry(entry: DirEntry, location: Path) -> Result<ObjectMeta> {
898-
let metadata = entry.metadata().map_err(|e| Error::Metadata {
899-
source: e.into(),
900-
path: location.to_string(),
901-
})?;
902-
convert_metadata(metadata, location)
897+
fn convert_entry(entry: DirEntry, location: Path) -> Result<Option<ObjectMeta>> {
898+
match entry.metadata() {
899+
Ok(metadata) => convert_metadata(metadata, location).map(Some),
900+
Err(e) => {
901+
if let Some(io_err) = e.io_error() {
902+
if io_err.kind() == ErrorKind::NotFound {
903+
return Ok(None);
904+
}
905+
}
906+
Err(Error::Metadata {
907+
source: e.into(),
908+
path: location.to_string(),
909+
})?
910+
}
911+
}
903912
}
904913

905914
fn last_modified(metadata: &Metadata) -> DateTime<Utc> {

0 commit comments

Comments
 (0)