lib/fiona7/complex_object.rb in infopark_fiona7-1.6.1.1.1 vs lib/fiona7/complex_object.rb in infopark_fiona7-1.6.1.1.5

- old
+ new

@@ -1,7 +1,11 @@ +require 'fiona7/binary_files_cleaner' + module Fiona7 class ComplexObject + include Fiona7::BinaryFilesCleaner + def initialize(obj) @obj = obj end def widgets @@ -9,16 +13,26 @@ links = @obj[:X_widget_pool] || [] WriteObj.where(obj_id: links.map {|l| l.destination_object_id }).to_a.to_set end def binaries + referenced = [] type_definition = Fiona7::TypeRegister.instance.read_mangled(@obj.obj_class) type_definition.attrs.each do |attribute| if attribute.type == :binary && attribute.real_name != "blob" - (obj[attribute.real_name] || []).each do |link| + (@obj[attribute.real_name] || []).each do |link| referenced << link.destination_object + Rails.logger.debug("referenced #{referenced}") end end end + referenced end + + def check_binaries + binaries.each do |binary| + unrelease_unused(binary) + end + end + end end