class Refile::Backend::FileSystemHashed

Public Instance Methods

exists?(id) click to toggle source
# File lib/refile/backend/file_system_hashed.rb, line 13
          def exists?(id)
  return true if ::File.exist?(path(id))

  if ::File.exist?(original_path(id))
    FileUtils.mkdir_p(::File.dirname(path(id)))
    FileUtils.mv(original_path(id), path(id))
    return true
  end

  false
end
original_path(id) click to toggle source
# File lib/refile/backend/file_system_hashed.rb, line 29
          def original_path(id)
  ::File.join(@directory, id)
end
path(id, create = false) click to toggle source
# File lib/refile/backend/file_system_hashed.rb, line 25
          def path(id, create = false)
  ::File.join(@directory, id.scan(/.{2}/).first(4), id)
end
upload(uploadable) click to toggle source
# File lib/refile/backend/file_system_hashed.rb, line 4
                  def upload(uploadable)
  id = @hasher.hash(uploadable)
  path = path(id)
  FileUtils.mkdir_p(::File.dirname(path))
  IO.copy_stream(uploadable, path)

  Refile::File.new(self, id)
end