Skip to content

Commit

Permalink
fix prefix offset when not using an s3 prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
pwinckles committed Jul 15, 2021
1 parent 3856d87 commit 360236d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/ocfl/store/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,18 +595,23 @@ impl S3Client {
..Default::default()
}))?;

let prefix_offset = if self.prefix.is_empty() {
0
} else {
self.prefix.len() + 1
};

if let Some(contents) = &result.contents {
for object in contents {
objects.push(object.key.as_ref().unwrap()[self.prefix.len() + 1..].to_owned());
objects.push(object.key.as_ref().unwrap()[prefix_offset..].to_owned());
}
}

if let Some(prefixes) = &result.common_prefixes {
for prefix in prefixes {
let length = prefix.prefix.as_ref().unwrap().len() - 1;
directories.push(
prefix.prefix.as_ref().unwrap()[self.prefix.len() + 1..length].to_owned(),
);
directories
.push(prefix.prefix.as_ref().unwrap()[prefix_offset..length].to_owned());
}
}

Expand Down

0 comments on commit 360236d

Please sign in to comment.