ElijahGlover / Umbraco-S3-Provider

Amazon Web Services S3 IFileSystem provider for Umbraco
46 stars 34 forks source link

GetDirectories issue when hostname not provided #20

Closed tcmorris closed 7 years ago

tcmorris commented 7 years ago

Hey, this fixes an issue we came across where GetDirectories was returning no results because the path becomes the same default as the bucket hostname.

We haven't provided a hostname as per the documentation, since we are using virtual path provider. https://github.com/ElijahGlover/Umbraco-S3-Provider#virtual-path-provider-recommended-for-umbraco--735

You can see in BucketFileSystem > GetDirectories on line 117, the path gets set to "/", and also in BucketExtensions when parsing the bucket hostname, if none is provided, you will also get "/".

This causes a problem with ResolveBucketPath as line 85 will now kick in, which means that line 88 doesn't match anymore and the code continues to run and you end up with media// as your Prefix for the GetDirectories request, which doesn't return any results.

I've added a check to line 84 and added some more tests to confirm what should happen.

This particular issue came about when we noticed that our media folders were not incrementing correctly in Umbraco, and tracked that down to this code that Umbraco calls to retrieve the list of directories from the file system provider (i.e. this package): https://github.com/umbraco/Umbraco-CMS/blob/c09cd95eb6a9faa587f81afb79d543652c3f48bd/src/Umbraco.Core/IO/MediaFileSystem.cs#L186

PhilA1 commented 7 years ago

you are correct, I'm surprised we have noticed media being overwritten :) I possibly caused this with my latest pull request, sorry.

tcmorris commented 7 years ago

No worries, thanks for taking a look and merging this in. We also needed the forms fix, so all good :)

ElijahGlover commented 7 years ago

Brilliant & thanks. New version is available on the NuGet feed as version 1.0.29