Skip to content

A platform for community discussion. Free, open, simple.

FIX: don't generate an exception when trying to cleanup unexisting tmp letter avatars

Régis Hanolf10af7e44939
diff --git a/lib/letter_avatar.rb b/lib/letter_avatar.rb
index 93766c4b2d1..cad64a83c5f 100644
--- a/lib/letter_avatar.rb
+++ b/lib/letter_avatar.rb
@@ -105,12 +105,16 @@ class LetterAvatar
end
def cleanup_old
- skip = File.basename(cache_path)
- parent_path = File.dirname(cache_path)
- Dir.entries(parent_path).each do |path|
- unless ['.', '..'].include?(path) || path == skip
- FileUtils.rm_rf(parent_path + "/" + path)
+ begin
+ skip = File.basename(cache_path)
+ parent_path = File.dirname(cache_path)
+ Dir.entries(parent_path).each do |path|
+ unless ['.', '..'].include?(path) || path == skip
+ FileUtils.rm_rf(parent_path + "/" + path)
+ end
end
+ rescue Errno::ENOENT
+ # no worries, folder doesn't exists
end
end
end