-
Notifications
You must be signed in to change notification settings - Fork 839
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
Add GetOptions::head #4931
Merged
Merged
Add GetOptions::head #4931
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,35 +419,6 @@ impl ObjectStore for LocalFileSystem { | |
.await | ||
} | ||
|
||
async fn head(&self, location: &Path) -> Result<ObjectMeta> { | ||
let path = self.config.path_to_filesystem(location)?; | ||
let location = location.clone(); | ||
|
||
maybe_spawn_blocking(move || { | ||
let metadata = match metadata(&path) { | ||
Err(e) => Err(match e.kind() { | ||
ErrorKind::NotFound => Error::NotFound { | ||
path: path.clone(), | ||
source: e, | ||
}, | ||
_ => Error::Metadata { | ||
source: e.into(), | ||
path: location.to_string(), | ||
}, | ||
}), | ||
Ok(m) => match !m.is_dir() { | ||
true => Ok(m), | ||
false => Err(Error::NotFound { | ||
path, | ||
source: io::Error::new(ErrorKind::NotFound, "is directory"), | ||
}), | ||
}, | ||
}?; | ||
convert_metadata(metadata, location) | ||
}) | ||
.await | ||
} | ||
|
||
async fn delete(&self, location: &Path) -> Result<()> { | ||
let path = self.config.path_to_filesystem(location)?; | ||
maybe_spawn_blocking(move || match std::fs::remove_file(&path) { | ||
|
@@ -1604,15 +1575,15 @@ mod unix_test { | |
let path = root.path().join(filename); | ||
unistd::mkfifo(&path, stat::Mode::S_IRWXU).unwrap(); | ||
|
||
let location = Path::from(filename); | ||
integration.head(&location).await.unwrap(); | ||
|
||
// Need to open read and write side in parallel | ||
let spawned = tokio::task::spawn_blocking(|| { | ||
OpenOptions::new().write(true).open(path).unwrap(); | ||
OpenOptions::new().write(true).open(path).unwrap() | ||
}); | ||
|
||
let location = Path::from(filename); | ||
integration.head(&location).await.unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has to be moved after the spawn_blocking as it now will open the file, which will block until the writer opens it, I don't see this being an issue as the behaviour of a head request on a file that gets mutated behind the scenes are not exactly very well defined anyway 😅 |
||
integration.get(&location).await.unwrap(); | ||
|
||
spawned.await.unwrap(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This semicolon fixes a subtle bug, where the writer is immediately dropped which then causes subsequent opens to block. I'm actually somewhat surprised it has worked semi-reliably so far. By returning the File, we defer destruction until after we're done with the file