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 bucket setup in `AssetSync::Storage#bucket` 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 bucket folder
called `assets/` and another folder called `assets-temp/`. A situation
could arise where the latter folder has thousands/millions of files and
everything slows to a crawl while we wait for the bucket object to
initialize.

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 26, 2022
1 parent e729879 commit 2a67010
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 2a67010

Please sign in to comment.