#94 Files not deleted with project
This commit is contained in:
parent
f655adaaa6
commit
c2117d561a
@ -82,7 +82,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.project_root_files(project)
|
||||
visible.where(:dmsf_folder_id => nil, :project_id => project.if).order('name ASC')
|
||||
visible.where(:project_id => project.id, :dmsf_folder_id => nil).order('name ASC')
|
||||
end
|
||||
|
||||
def self.find_file_by_name(project, folder, name)
|
||||
|
||||
@ -87,6 +87,14 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if Setting.plugin_redmine_dmsf['dmsf_really_delete_files']
|
||||
dependencies = DmsfFileRevision.where(:disk_filename => self.disk_filename).all.count
|
||||
File.delete(self.disk_file) if dependencies <= 1 && File.exist?(self.disk_file)
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
# In a static call, we find the first matched record on base object type and
|
||||
# then run the access_grouped call against it
|
||||
def self.access_grouped(revision_id)
|
||||
|
||||
@ -31,9 +31,8 @@ module RedmineDmsf
|
||||
unloadable
|
||||
alias_method_chain :copy, :dmsf
|
||||
|
||||
has_many :dmsf_files, :class_name => 'DmsfFile', :foreign_key => 'project_id', :conditions => { :dmsf_folder_id => nil }
|
||||
#Fix: should only be root folders not, all folders
|
||||
has_many :dmsf_folders, :class_name => 'DmsfFolder', :foreign_key => 'project_id', :conditions => {:dmsf_folder_id => nil}, :dependent => :destroy
|
||||
has_many :dmsf_files, :class_name => 'DmsfFile', :foreign_key => 'project_id', :conditions => { :dmsf_folder_id => nil }, :dependent => :destroy
|
||||
has_many :dmsf_folders, :class_name => 'DmsfFolder', :foreign_key => 'project_id', :conditions => {:dmsf_folder_id => nil}, :dependent => :destroy
|
||||
has_many :dmsf_workflows, :dependent => :destroy
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user