app/models/post/mirror_methods.rb
# On :normal, upload all files to all mirrors except :previews_only ones.
# On :previews_only, upload previews to previews_only mirrors.
On :normal, upload all files to all mirrors except :previews_only ones.
On :previews_only, upload previews to previews_only mirrors.
On : normal upload all files to all mirrors except : previews_only ones . On : previews_only upload previews to previews_only mirrors .
def upload_to_mirrors_internal(mode = :normal)
    files_to_copy = []
    if mode != :previews_only
      files_to_copy << file_path
      files_to_copy << sample_path if self.has_sample?
      files_to_copy << jpeg_path if self.has_jpeg?
    end
    files_to_copy << preview_path if self.image?
    files_to_copy = files_to_copy.uniq
    local_base = "#{Rails.root}/public/data/"
    dirs = []
    files_to_copy.each do |file|
      dirs << File.dirname(file[local_base.length, file.length])
    end
    options = {}
    if mode == :previews_only
      options[:previews_only] = true
    end
    Mirrors.create_mirror_paths(dirs, options)
    files_to_copy.each do |file|
      Mirrors.copy_file_to_mirrors(file, options)
    end
  end
def upload_to_mirrors_internal ( mode = :normal ) files_to_copy = [ ] if mode != :previews_only files_to_copy << file_path files_to_copy << sample_path if self . has_sample? files_to_copy << jpeg_path if self . has_jpeg? end files_to_copy << preview_path if self . image? files_to_copy = files_to_copy . uniq local_base = "#{Rails.root}/public/data/" dirs = [ ] files_to_copy . each do | file | dirs << File . dirname ( file [ local_base . length , file . length ] ) end options = { } if mode == :previews_only options [ :previews_only ] = true end Mirrors . create_mirror_paths ( dirs , options ) files_to_copy . each do | file | Mirrors . copy_file_to_mirrors ( file , options ) end end
On :normal, upload all files to all mirrors except :previews_only ones.
On : normal upload all files to all mirrors except : previews_only ones .
# CONFIG[:data_dir] is equivalent to our local_base.
mode