Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  specify next release
  run the periodic ci when the workflow is updated
  update changelog
  add warning when using filesystem adapter of unexpected behaviour
  use separate bucket to run proofs
  fix query string encoding
  • Loading branch information
Baptouuuu committed Jun 17, 2024
2 parents 8c060ed + 034ecd9 commit 1e6b067
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
# part of the url
S3_URL=
S3_REGION=
# don't use the same bucket as the properties don't expect a file and a
# directory to have the same name (which can be generated by other proofs)
S3_PROPERTIES_URL=
S3_PROPERTIES_REGION=
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
env:
S3_URL: ${{ secrets.S3_URL_PROOFS }}
S3_REGION: ${{ secrets.S3_REGION_PROOFS }}
S3_PROPERTIES_URL: ${{ secrets.S3_PROPERTIES_URL_PROOFS }}
S3_PROPERTIES_REGION: ${{ secrets.S3_PROPERTIES_REGION_PROOFS }}
blackbox_coverage:
runs-on: ${{ matrix.os }}
concurrency:
Expand Down Expand Up @@ -58,6 +60,8 @@ jobs:
ENABLE_COVERAGE: 'true'
S3_URL: ${{ secrets.S3_URL_COVERAGE }}
S3_REGION: ${{ secrets.S3_REGION_COVERAGE }}
S3_PROPERTIES_URL: ${{ secrets.S3_PROPERTIES_URL_COVERAGE }}
S3_PROPERTIES_REGION: ${{ secrets.S3_PROPERTIES_REGION_COVERAGE }}
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/periodic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Periodic CI
on:
schedule:
- cron: '0 1 * * 1'
push:
paths:
- '.github/workflows/periodic.yml'

jobs:
blackbox:
Expand Down Expand Up @@ -35,3 +38,5 @@ jobs:
env:
S3_URL: ${{ secrets.S3_URL_PROOFS }}
S3_REGION: ${{ secrets.S3_REGION_PROOFS }}
S3_PROPERTIES_URL: ${{ secrets.S3_PROPERTIES_URL_PROOFS }}
S3_PROPERTIES_REGION: ${{ secrets.S3_PROPERTIES_REGION_PROOFS }}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 4.1.2 - 2024-06-17

### Fixed

- Continuation token used when paginating a listed wasn't properly encoded

## 4.1.1 - 2024-06-14

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ $data
static fn() => null, // do something if there is no images
);
```

> [!WARNING]
> A bucket can contain a file and a directory with the same name. This is not supported by `innmind/filesystem` adapters. This means that if you use `Innmind\S3\Filesystem\Adapter` on a bucket where there is a file and a directory with the same name it will result in unexpected behaviour or an exception.
4 changes: 2 additions & 2 deletions proofs/adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

$os = Resilient::of(OSFactory::build());
$bucket = Factory::of($os)->build(
Url::of(\getenv('S3_URL') ?? throw new Exception('Env var missing')),
Region::of(\getenv('S3_REGION') ?? throw new Exception('Env var missing')),
Url::of(\getenv('S3_PROPERTIES_URL') ?? throw new Exception('Env var missing')),
Region::of(\getenv('S3_PROPERTIES_REGION') ?? throw new Exception('Env var missing')),
);

yield properties(
Expand Down
29 changes: 21 additions & 8 deletions src/Bucket/OverHttp.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ public function list(Path $path): Sequence
throw new LogicException("Only a directory can be listed, got '{$path->toString()}'");
}

if ($path->equals(Path::none())) {
$query = 'delimiter=%2F&list-type=2';
$prefixLength = 0;
} else {
$query = 'delimiter=%2F&list-type=2&prefix='.\rawurlencode($path->toString());
$query = [
'delimiter' => '/',
'list-type' => 2,
];
$prefixLength = 0;

if (!$path->equals(Path::none())) {
$query['prefix'] = $path->toString();
$prefixLength = Str::of($path->toString(), Str\Encoding::ascii)->length();
}

Expand All @@ -144,18 +147,28 @@ public function list(Path $path): Sequence
*/
private function paginate(
Path $path,
string $query,
array $query,
string $next = null,
): Sequence {
if (\is_string($next)) {
$next = '&continuation-token='.$next;
$next = ['continuation-token' => $next];
} else {
$next = [];
}

return ($this->fulfill)($this->request(
Method::get,
$this->bucket->path(),
null,
Query::of($query.(string) $next),
Query::of(\http_build_query(
[
...$next,
...$query,
],
'',
'&',
\PHP_QUERY_RFC3986,
)),
))
->maybe()
->map(static fn($success) => $success->response()->body())
Expand Down

0 comments on commit 1e6b067

Please sign in to comment.