Skip to content

Commit

Permalink
Keep backups, even when they're old. (#2734) (#2912)
Browse files Browse the repository at this point in the history
Recently, we encountered an issue with webpacker removing our previous assets
during the webpacker:clean task, and not keeping the specified number of
backups. We expected the [behavior from sprockets][sprockets], in which assets are
kept if under age or within the count limit. However, webpacker only keeps
assets if under age *AND* within the count limit.

I think this should work like sprockets and has perhaps been overlooked.

[sprockets]: https://github.com/rails/sprockets/blob/358f83ff09a77f69ac17543a9b1d127737060f00/lib/sprockets/manifest.rb#L258-L259

Backport-PR-URL: #2912

Co-authored-by: Brad Dunbar <dunbarb2@gmail.com>
  • Loading branch information
Pezmc and braddunbar committed Apr 27, 2021
1 parent 745837a commit eedd2ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/webpacker/commands.rb
Expand Up @@ -23,7 +23,7 @@ def clean(count = 2, age = 3600)
.each_with_index
.drop_while do |(mtime, _), index|
max_age = [0, Time.now - Time.at(mtime)].max
max_age < age && index < count
max_age < age || index < count
end
.each do |(_, files), index|
files.each do |file|
Expand Down

0 comments on commit eedd2ab

Please sign in to comment.