Skip to content

Commit

Permalink
Drop trailing slash of prefix in #get_local_files
Browse files Browse the repository at this point in the history
The local filesystem glob in `AssetSync::Storage#get_local_files` uses
fuzzy matching when config.prefix is present. This can present a problem
in some cases, as it doesn't allow for distinguishing between (e.g.) a
folder called `assets/` and another folder called `assets-temp/`. A
situation could arise where the latter folder has thousands/millions of
files and we mistakenly publish local-only files, or worse we could
clobber another directory in the bucket managed in a completely
different context.

This change allows developers to be more specific in their
`config.prefix` by using a trailing slash for their folder name.
  • Loading branch information
alanbrent committed Jan 27, 2022
1 parent e729879 commit 26c45ed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/asset_sync/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def get_local_files

log "Using: Directory Search of #{path}/#{self.config.assets_prefix}"
Dir.chdir(path) do
to_load = self.config.assets_prefix.present? ? "#{self.config.assets_prefix}/**/**" : '**/**'
to_load = self.config.assets_prefix.present? ? File.join(self.config.assets_prefix, '/**/**') : '**/**'
Dir[to_load]
end
end
Expand Down

0 comments on commit 26c45ed

Please sign in to comment.