use cached tree map when finding files
This commit is contained in:
+8
-7
@@ -46,13 +46,14 @@ module Gollum
|
||||
#
|
||||
# Returns a Gollum::File or nil if the file could not be found.
|
||||
def find(name, version)
|
||||
if commit = @wiki.repo.commit(version)
|
||||
if (blob = commit.tree / name) && blob.is_a?(Grit::Blob)
|
||||
@blob = blob
|
||||
@path = name
|
||||
@version = commit
|
||||
self
|
||||
end
|
||||
checked = name.downcase
|
||||
map = @wiki.tree_map_for(version)
|
||||
sha = @wiki.ref_map[version] || version
|
||||
if pair = map.detect { |(path, _)| path == checked }
|
||||
@path = name
|
||||
@blob = Grit::Blob.create(@wiki.repo, :id => pair.last, :name => ::File.basename(@path))
|
||||
@version = Grit::Commit.create(@wiki.repo, :id => sha)
|
||||
self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user