Method: OMF::Web::FileContentRepository#create_content_proxy_for
- Defined in:
- lib/omf-web/content/file_repository.rb
#create_content_proxy_for(content_descr) ⇒ Object
Load content described by either a hash or a straightforward path and return a ‘ContentProxy’ holding it.
If descr is true, return nil if file for which proxy is requested already exists.
@return: Content proxy
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/omf-web/content/file_repository.rb', line 28 def create_content_proxy_for(content_descr) path = _get_path(content_descr) # TODO: Make sure that key is really unique across multiple repositories descr = descr ? descr.dup : {} url = @url_prefix + path key = Digest::MD5.hexdigest(url) descr[:url] = url descr[:url_key] = key descr[:path] = path descr[:name] = url # Should be something human digestable if (descr[:strictly_new]) Dir.chdir(@top_dir) do return nil if File.exist?(path) end end proxy = ContentProxy.create(descr, self) return proxy end |