Add release document, use .extend rather than .join

This commit is contained in:
asonix 2024-01-11 16:48:18 -06:00
parent 4591aa3e11
commit 9ed90efed4
3 changed files with 40 additions and 8 deletions

View file

@ -674,9 +674,4 @@ client_timeout = 30
# Note that in order for clients to fetch media from this URL directly, any server between the
# client and pict-rs must not be configured to follow redirects, or else that server will fetch from
# this public URL and serve the file itself.
#
# Note also that if a a path is to be included in the URL, it must have a trailing slash or else it
# will be overwritten by the filepath.
# e.g. https://example.com/sub/path will turn into https://example.com/sub/001/001/UUID
# while https://example.com/sub/path/ will turn into https://example.com/sub/path/001/001/UUID
public_endpoint = "https://pict-rs.some.cdn.example.com/subpath/"

32
releases/0.5.1.md Normal file
View file

@ -0,0 +1,32 @@
# pict-rs 0.5.1
## Overview
Just a quick point release to better support different public_endpoint usecases. Including paths for
the public_endpoint configuration is now supported.
### Changes
- [Support Paths in PUBLIC_ENDPOINT](#support-paths-in-public-endpoints)
## Upgrade Notes
There's no significant changes from 0.5.0, so upgrading should be as simple as pulling a new version
of pict-rs.
## Descriptions
### Support Paths in PUBLIC_ENDPOINT
The `public_endpoint` configuration option for object storage has been updated to allow setting
paths at which the files are available. Previously any set path would be overridden, treating the
file's relative path as it's absolute path. Now pict-rs will serve files respecting configured
paths.
Example
```toml
public_endpoint = "https://example.com/sub/path"
```
This will produce URLs to `https://example.com/sub/path/$filepath`

View file

@ -403,9 +403,14 @@ impl Store for ObjectStore {
}
fn public_url(&self, identifier: &Arc<str>) -> Option<url::Url> {
self.public_endpoint
.as_ref()
.and_then(|endpoint| endpoint.join(identifier.as_ref()).ok())
self.public_endpoint.clone().and_then(|mut endpoint| {
endpoint
.path_segments_mut()
.ok()?
.pop_if_empty()
.extend(identifier.as_ref().split('/'));
Some(endpoint)
})
}
#[tracing::instrument(skip(self))]