AssetSync / asset_sync

Synchronises Assets between Rails and S3
1.88k stars 346 forks source link

Bucket name gets confused with config.assets.prefix #399

Open SaimonL opened 4 years ago

SaimonL commented 4 years ago

I don't know where to post this bug.

The problem is if you set the config.assets.prefix to the folder you want to put your static compiled assets in to, rails or asset_sync or fog-aws gets confused and use that as a bucket name.

For an example:

config.asset_sync.fog_directory = ENV['FOG_DIRECTORY']
config.assets.prefix = '/production/assets'

This will result in error message:

<?xml version="1.0" encoding="UTF-8"?>\n<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>
<Key>assets/application-e3315f5ba5eabff081ffb04b6739f7847a31fb8131b128c8a9193ff59226b010.css</Key>
<BucketName>production</BucketName>
<Resource>/production/assets/application-e3315f5ba5eabff081ffb04b6739f7847a31fb8131b128c8a9193ff59226b010.css</Resource>
<RequestId>15F7DDD2C34819B8</RequestId>
<HostId>7d382a88-687c-4695-b0c8-....</HostId>
</Error><?xml version="1.0" encoding="UTF-8"?>

Now if you set the config.assets.prefix to the bucket name then everything works fine.

config.asset_sync.fog_directory = ENV['FOG_DIRECTORY']
config.assets.prefix = ENV['FOG_DIRECTORY']

If you set config.assets.prefix to empty string then it will fail with bucket name being "assets".

More Info

OS: Ubuntu 18.04 LTS Asset Server: MinIO/RELEASE.2020-02-27T00-23-05Z Rails 5.2.4.1 Ruby 2.6.5

Bundle List Gems included by the bundle:

PikachuEXE commented 4 years ago

Not sure if related: #38

The bucket/remote folder is fetch with assets_prefix & fog_directory together https://github.com/AssetSync/asset_sync/blob/v2.10.0/lib/asset_sync/storage.rb#L23-L26