From 624f687cbdd8cb47531f7bfe1e77006a293ae64e Mon Sep 17 00:00:00 2001 From: Brad Dunbar Date: Tue, 22 Sep 2020 04:01:30 -0400 Subject: [PATCH] Keep backups, even when they're old. (#2734) 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 --- lib/webpacker/commands.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/webpacker/commands.rb b/lib/webpacker/commands.rb index e7a97b15b..d384218be 100644 --- a/lib/webpacker/commands.rb +++ b/lib/webpacker/commands.rb @@ -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|