Skip to content

Commit

Permalink
Keep backups, even when they're old. (rails#2734)
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
  • Loading branch information
braddunbar authored and oboxodo committed Feb 3, 2021
1 parent b46ce72 commit 624f687
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 624f687

Please sign in to comment.