mirror of
https://github.com/redmine/redmine.git
synced 2026-05-06 07:15:33 +02:00
Deletes thumbnails when the attachment diskfile is deleted (#30177).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@17736 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -216,7 +216,7 @@ class Attachment < ActiveRecord::Base
|
||||
size = Setting.thumbnails_size.to_i
|
||||
end
|
||||
size = 100 unless size > 0
|
||||
target = File.join(self.class.thumbnails_storage_path, "#{digest}_#{filesize}_#{size}.thumb")
|
||||
target = thumbnail_path(size)
|
||||
|
||||
begin
|
||||
Redmine::Thumbnail.generate(self.diskfile, target, size)
|
||||
@@ -463,6 +463,14 @@ class Attachment < ActiveRecord::Base
|
||||
if disk_filename.present? && File.exist?(diskfile)
|
||||
File.delete(diskfile)
|
||||
end
|
||||
Dir[thumbnail_path("*")].each do |thumb|
|
||||
File.delete(thumb)
|
||||
end
|
||||
end
|
||||
|
||||
def thumbnail_path(size)
|
||||
File.join(self.class.thumbnails_storage_path,
|
||||
"#{digest}_#{filesize}_#{size}.thumb")
|
||||
end
|
||||
|
||||
def sanitize_filename(value)
|
||||
|
||||
Reference in New Issue
Block a user