Skip to content

Commit eedd2ab

Browse files
Pezmcbraddunbar
andauthored
Keep backups, even when they're old. (#2734) (#2912)
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>
1 parent 745837a commit eedd2ab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/webpacker/commands.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def clean(count = 2, age = 3600)
2323
.each_with_index
2424
.drop_while do |(mtime, _), index|
2525
max_age = [0, Time.now - Time.at(mtime)].max
26-
max_age < age && index < count
26+
max_age < age || index < count
2727
end
2828
.each do |(_, files), index|
2929
files.each do |file|

0 commit comments

Comments
 (0)