guzzle-cache-middleware icon indicating copy to clipboard operation
guzzle-cache-middleware copied to clipboard

Special characters make the SubfolderNamingStrategy fail

Open Tobion opened this issue 6 years ago • 3 comments

When there are special characters in the URI path that are not allowed by the filesystem (like : on Windows), the MockStorageAdapter using SubfolderNamingStrategy fails with

Symfony\Component\Filesystem\Exception\IOException: Failed to create "/vagrant/tests/fixtures/guzzle/.../transform;key=rest:api": mkdir(): Input/output error.

And unfortunately one cannot reconfigure the adapters, making the caching / mocking unusable.

Tobion avatar Jan 15 '18 17:01 Tobion

Good point. I think we should simply ignore reserved characters for all operating systems, when fetching the path information from the URI.

csarrazi avatar Jan 16 '18 13:01 csarrazi

Btw, the https://github.com/csarrazi/guzzle-cache-middleware/blob/master/src/Adapter/MockStorageAdapter.php does not seem necessary. You could use the https://github.com/csarrazi/guzzle-cache-middleware/blob/master/src/Adapter/PsrAdapter.php also for the mock storage. In the https://github.com/csarrazi/CsaGuzzleBundle you could use the symfony filesystem cache adapter without ttl and the IdentityMarshaller (or a custom one for responses).

Tobion avatar Mar 07 '20 20:03 Tobion

This way the library also wouldn't need to worry about such things like invalid chars. But the cache key would usually not translate to the filename as the key is likely hashed.

Tobion avatar Mar 07 '20 20:03 Tobion