File Storage Directory does not change #522
This commit is contained in:
parent
68c68cdf79
commit
3a4d3e8b2b
8
Gemfile
8
Gemfile
@ -22,11 +22,11 @@
|
||||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rubyzip', '>= 1.0.0'
|
||||
gem 'zip-zip' # Just to avoid 'cannot load such file -- zip/zip' error
|
||||
gem 'rubyzip'
|
||||
gem 'zip-zip'
|
||||
gem 'simple_enum'
|
||||
gem 'uuidtools', '~> 2.1.1'
|
||||
gem 'dav4rack', '~> 0.3.0'
|
||||
gem 'uuidtools'
|
||||
gem 'dav4rack'
|
||||
|
||||
group :xapian do
|
||||
gem 'xapian-full-alaveteli', :require => false
|
||||
|
||||
@ -205,9 +205,15 @@ class DmsfUploadController < ApplicationController
|
||||
|
||||
if new_revision.save
|
||||
new_revision.assign_workflow(commited_file[:dmsf_workflow_id])
|
||||
FileUtils.mv(commited_disk_filepath, new_revision.disk_file)
|
||||
file.set_last_revision new_revision
|
||||
@files.push(file)
|
||||
begin
|
||||
FileUtils.mv(commited_disk_filepath, new_revision.disk_file)
|
||||
file.set_last_revision new_revision
|
||||
@files.push(file)
|
||||
rescue Exception => e
|
||||
Rails.logger.error e.message
|
||||
flash[:error] = e.message
|
||||
failed_uploads.push(file)
|
||||
end
|
||||
else
|
||||
failed_uploads.push(commited_file)
|
||||
end
|
||||
|
||||
@ -96,19 +96,22 @@ class DmsfFile < ActiveRecord::Base
|
||||
@@storage_path = nil
|
||||
|
||||
def self.storage_path
|
||||
unless @@storage_path.present?
|
||||
@@storage_path = Setting.plugin_redmine_dmsf['dmsf_storage_directory'].strip if Setting.plugin_redmine_dmsf['dmsf_storage_directory'].present?
|
||||
@@storage_path = Pathname(Redmine::Configuration['attachments_storage_path']).join('dmsf') if @@storage_path.blank? && Redmine::Configuration['attachments_storage_path'].present?
|
||||
@@storage_path = Rails.root.join('files/dmsf').to_s if @@storage_path.blank?
|
||||
Dir.mkdir(@@storage_path) unless File.exists?(@@storage_path)
|
||||
end
|
||||
path = Setting.plugin_redmine_dmsf['dmsf_storage_directory'].strip if Setting.plugin_redmine_dmsf['dmsf_storage_directory'].present?
|
||||
path = Pathname(Redmine::Configuration['attachments_storage_path']).join('dmsf') if path.blank? && Redmine::Configuration['attachments_storage_path'].present?
|
||||
path = Rails.root.join('files/dmsf').to_s if path.blank?
|
||||
DmsfFile.storage_path = path if path != @@storage_path
|
||||
@@storage_path
|
||||
end
|
||||
|
||||
# Lets introduce a write for storage path, that way we can also
|
||||
# better interact from test-cases etc
|
||||
def self.storage_path=(obj)
|
||||
@@storage_path = obj
|
||||
def self.storage_path=(path)
|
||||
begin
|
||||
FileUtils.mkdir_p(path) unless File.exists?(path)
|
||||
rescue Exception => e
|
||||
Rails.logger.error e.message
|
||||
end
|
||||
@@storage_path = path
|
||||
end
|
||||
|
||||
def self.find_file_by_name(project, folder, name)
|
||||
|
||||
@ -136,7 +136,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
project_base = project.identifier.gsub(/[^\w\.\-]/,'_')
|
||||
storage_base << "/p_#{project_base}"
|
||||
end
|
||||
Dir.mkdir(storage_base) unless File.exists?(storage_base)
|
||||
FileUtils.mkdir_p(storage_base) unless File.exists?(storage_base)
|
||||
"#{storage_base}/#{self.disk_filename}"
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user