OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/app/models/backup.rb

45 lines
1.1 KiB

class Backup < Export
class << self
def permission
:create_backup
end
def include_attachments?
val = OpenProject::Configuration.backup_include_attachments
val.nil? ? true : val.to_s.to_bool # default to true
end
##
# Don't include attachments in archive if they are larger than
# this value combined.
def attachment_size_max_sum_mb
(OpenProject::Configuration.backup_attachment_size_max_sum_mb.presence || 1024).to_i
end
def attachments_query
Attachment
.where.not(container_type: nil)
.where.not(container_type: Export.name)
end
def attachments_size_in_mb(attachments_query = self.attachments_query)
attachments_query.pluck(:filesize).sum / 1024.0 / 1024.0
end
def attachments_size_in_bounds?(attachments_query = self.attachments_query, max: self.attachment_size_max_sum_mb)
attachments_size_in_mb(attachments_query) <= max
end
end
acts_as_attachable(
view_permission: permission,
add_permission: permission,
delete_permission: permission,
only_user_allowed: true
)
def ready?
attachments.any?
end
end