mod/core/set/all/trash.rb in card-1.101.4 vs mod/core/set/all/trash.rb in card-1.101.5
- old
+ new
@@ -34,10 +34,11 @@
end
end
def delete_files_with_id file_id
raise Card::Error, t(:core_exception_almost_deleted) if Card.exists?(file_id)
+
::FileUtils.rm_rf "#{dir}/#{file_id}", secure: true
end
def all_file_ids
dir = Card.paths["files"].existent.first
@@ -63,10 +64,11 @@
end
end
def add_to_trash args
return if new_card?
+
yield args.merge trash: true
end
event :manage_trash, :prepare_to_store, on: :create do
pull_from_trash!
@@ -75,10 +77,11 @@
end
def pull_from_trash!
return unless (id = Card::Lexicon.id key) # name is already known
return unless (trashed_card = Card.where(id: id).take)&.trash
+
# confirm name is actually in trash
db_attributes["id"] = trashed_card.db_attributes["id"]
# id_in_database returns existing card id
@@ -97,19 +100,20 @@
undeletable_all_rules_tags =
%w[default style layout create read update delete]
# FIXME: HACK! should be configured in the rule
- if junction? && left&.codename == :all &&
+ if compound? && left&.codename == :all &&
undeletable_all_rules_tags.member?(right.codename.to_s)
errors.add :delete, t(:core_error_indestructible, name: name)
end
errors.add :delete, t(:core_error_user_edits, name: name) if account && has_edits?
end
event :validate_delete_children, after: :validate_delete, on: :delete do
return if errors.any?
+
each_child do |child|
child.include_set_modules
delete_as_subcard child
# next if child.valid?
# child.errors.each do |field, message|