Skip to content

Commit 78a9f15

Browse files
authored
Merge pull request #8644 from GabrielNagy/PUP-11079
(PUP-11079) Tidy files with age equal or greater
2 parents 9deee73 + a76ae47 commit 78a9f15

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/puppet/type/tidy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def convert(unit, multi)
144144

145145
def tidy?(path, stat)
146146
# If the file's older than we allow, we should get rid of it.
147-
(Time.now.to_i - stat.send(resource[:type]).to_i) > value
147+
(Time.now.to_i - stat.send(resource[:type]).to_i) >= value
148148
end
149149

150150
munge do |age|

spec/unit/type/tidy_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,13 @@
280280
@ager.tidy?(@basepath, @stat)
281281
end
282282

283+
it "should return true if the specified age is 0" do
284+
@tidy[:age] = "0"
285+
expect(@stat).to receive(:mtime).and_return(Time.now)
286+
287+
expect(@ager).to be_tidy(@basepath, @stat)
288+
end
289+
283290
it "should return false if the file is more recent than the specified age" do
284291
expect(@stat).to receive(:mtime).and_return(Time.now)
285292

0 commit comments

Comments
 (0)