* finished Issue 48: Database Error WHen Searching With Redmine Search
* fixed minor errors in fulltext search git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@76 5e329b0b-a2ee-ea63-e329-299493fc886d
This commit is contained in:
parent
0c8250220a
commit
f733d05a5b
@ -64,10 +64,14 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
|
||||
def download_file
|
||||
if @file.deleted
|
||||
render_404
|
||||
else
|
||||
@revision = @file.last_revision
|
||||
Rails.logger.info "#{Time.now} from #{request.remote_ip}/#{request.env["HTTP_X_FORWARDED_FOR"]}: #{User.current.login} downloaded #{@project.identifier}://#{@file.dmsf_path_str} revision #{@revision.id}"
|
||||
send_revision
|
||||
end
|
||||
end
|
||||
|
||||
def download_revision
|
||||
@revision = DmsfFileRevision.find(params[:revision_id])
|
||||
|
||||
@ -278,17 +278,19 @@ class DmsfDetailController < ApplicationController
|
||||
end
|
||||
|
||||
if new_revision.save
|
||||
new_revision.copy_file_content(file_upload)
|
||||
file_upload.close
|
||||
File.delete(commited_disk_filepath)
|
||||
|
||||
if file.locked?
|
||||
DmsfFileLock.file_lock_state(file, false)
|
||||
flash[:notice] = l(:notice_file_unlocked)
|
||||
end
|
||||
file.save
|
||||
file.save!
|
||||
file.reload
|
||||
|
||||
# Need to save file first to generate id for it in case of creation.
|
||||
# File id is needed to properly generate revision disk filename
|
||||
new_revision.copy_file_content(file_upload)
|
||||
file_upload.close
|
||||
File.delete(commited_disk_filepath)
|
||||
|
||||
files.push(file)
|
||||
else
|
||||
failed_uploads.push(commited_file)
|
||||
|
||||
@ -189,7 +189,14 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
if !options[:titles_only] && $xapian_bindings_available
|
||||
database = nil
|
||||
begin
|
||||
database = Xapian::Database.new(Setting.plugin_redmine_dmsf["dmsf_index_database"].strip)
|
||||
rescue
|
||||
Rails.logger.warn "REDMAIN_XAPIAN ERROR: Xapian database is not properly set or initiated or is corrupted."
|
||||
end
|
||||
|
||||
unless database.nil?
|
||||
enquire = Xapian::Enquire.new(database)
|
||||
|
||||
queryString = tokens.join(' ')
|
||||
@ -215,7 +222,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
enquire.query = query
|
||||
matchset = enquire.mset(0, 1000)
|
||||
|
||||
if !matchset.nil?
|
||||
unless matchset.nil?
|
||||
matchset.matches.each {|m|
|
||||
docdata = m.document.data{url}
|
||||
dochash = Hash[*docdata.scan(/(url|sample|modtime|type|size)=\/?([^\n\]]+)/).flatten]
|
||||
@ -224,7 +231,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
dmsf_attrs = filename.split("_")
|
||||
next unless results.select{|f| f.id.to_s == dmsf_attrs[1]}.empty?
|
||||
|
||||
find_conditions = DmsfFile.merge_conditions(limit_options[:conditions], :id => dmsf_attrs[1] )
|
||||
find_conditions = DmsfFile.merge_conditions(limit_options[:conditions], :id => dmsf_attrs[1], :deleted => false )
|
||||
dmsf_file = DmsfFile.find(:first, :conditions => find_conditions )
|
||||
|
||||
if !dmsf_file.nil?
|
||||
@ -254,6 +261,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
[results, results_count]
|
||||
end
|
||||
|
||||
@ -155,7 +155,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
while File.exist?(File.join(DmsfFile.storage_path, "#{timestamp}_#{self.id}_#{filename}"))
|
||||
timestamp.succ!
|
||||
end
|
||||
"#{timestamp}_#{id}_#{filename}"
|
||||
"#{timestamp}_#{file.id}_#{filename}"
|
||||
end
|
||||
|
||||
def copy_file_content(open_file)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user