Skip to content

Commit

Permalink
allow ls without path name
Browse files Browse the repository at this point in the history
  • Loading branch information
samster25 committed Sep 14, 2023
1 parent 9a61a90 commit 43e3e33
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/daft-io/src/s3_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ impl From<Error> for super::Error {
source: err.into(),
},
},
UnableToListObjects { path, source } => match source.into_service_error() {
ListObjectsV2Error::NoSuchBucket(no_such_key) => super::Error::NotFound {
path,
source: no_such_key.into(),
},
ListObjectsV2Error::Unhandled(v) => super::Error::Unhandled {
path,
msg: DisplayErrorContext(v).to_string(),
},
err => super::Error::UnableToOpenFile {
path,
source: err.into(),
},
},
InvalidUrl { path, source } => super::Error::InvalidUrl { path, source },
UnableToReadBytes { path, source } => super::Error::UnableToReadBytes {
path,
Expand Down Expand Up @@ -641,6 +655,8 @@ impl ObjectSource for S3LikeSource {
) -> super::Result<LSResult> {
let parsed = url::Url::parse(path).with_context(|_| InvalidUrlSnafu { path })?;
let delimiter = delimiter.unwrap_or("/");
log::warn!("{:?}", parsed);

let bucket = match parsed.host_str() {
Some(s) => Ok(s),
None => Err(Error::InvalidUrl {
Expand All @@ -654,6 +670,7 @@ impl ObjectSource for S3LikeSource {
.strip_prefix('/')
.map(|k| k.strip_suffix('/').unwrap_or(k));
let key = key.unwrap_or("");

// assume its a directory first
let lsr = {
let permit = self
Expand Down Expand Up @@ -701,9 +718,6 @@ impl ObjectSource for S3LikeSource {
} else {
Ok(lsr)
}
// } else {
// Err(Error::NotAFile { path: path.into() }.into())
// }
}
}

Expand Down

0 comments on commit 43e3e33

Please sign in to comment.