Skip to content

fix: remove parent directories to mimic s3 behaviour #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 4, 2023

Conversation

jeqo
Copy link
Contributor

@jeqo jeqo commented Apr 20, 2023

When a directory is emptied on S3, the parent keys are removed until an object is found

@jeqo jeqo requested a review from a team as a code owner April 20, 2023 14:07
Copy link
Contributor

@ivanyu ivanyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small comment + some tests would be nice

@@ -64,19 +72,33 @@ public InputStream fetch(final String key, final int from, final int to) throws
throw new IllegalArgumentException("from cannot be more than to, from=" + from + ", to=" + to + " given");
}

final Path path = Path.of(fsRoot, key);
final Path path = fsRoot.resolve(key);
final long fileSize = Files.size(path);
if (to > fileSize) {
throw new IllegalArgumentException("to cannot be bigger than file size, to="
+ to + ", file size=" + fileSize + " given");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we should return until the end of the file.
S3 (even though I haven't found it in the docs) doesn't return failure when fetching by range, but returns until the end of the file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question but I believe we should not rely on this and this should be an error, it's better to fail fast then in the end trying to figure out why a part of the batch is missing.

@jeqo jeqo requested a review from ivanyu April 20, 2023 20:11
Copy link
Contributor

@AnatolyPopov AnatolyPopov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some test-related comments

@jeqo jeqo requested a review from AnatolyPopov April 21, 2023 08:33
@jeqo jeqo force-pushed the jeqo/fix-fs-delete branch from 120173d to f4041d2 Compare April 21, 2023 17:45
@jeqo jeqo force-pushed the jeqo/fix-fs-delete branch from 2afbfe8 to c7ef40f Compare May 3, 2023 07:15
@jeqo jeqo force-pushed the jeqo/fix-fs-delete branch from c7ef40f to 0452247 Compare May 3, 2023 07:16
@jeqo jeqo requested a review from AnatolyPopov May 3, 2023 09:25
Copy link
Contributor

@AnatolyPopov AnatolyPopov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AnatolyPopov AnatolyPopov merged commit 8369a14 into new-implementation May 4, 2023
@AnatolyPopov AnatolyPopov deleted the jeqo/fix-fs-delete branch May 4, 2023 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants