app/controllers/concerns/create_dip.rb
# create a zip file from a dip
create a zip file from a dip
create a zip file from a dip
def create_zip (dataset_id, path_to_dipfiles)
    ds = Dlibhydra::Dataset.find(dataset_id)
    zip_dir = File.join(ENV['DIP_LOCATION'], "zips", dataset_id)
    zip_file = File.join(zip_dir, "dataset.zip")
    FileUtils.mkdir_p(zip_dir)
    result = ""
    begin
      result = `zip -rqj #{zip_file} #{path_to_dipfiles} 2>&1`
      raise if !result.empty? or !$?.success?
    rescue => e
      handle_exception(e, "Failed to create zip file for dataset " + dataset_id + ", output: " + result, "Failed to create zip file for dataset " + dataset_id + ", output: " + result, true)
    end
  rescue => e
    handle_exception(e, "Unable to create zip file for dataset " + dataset_id, "Unable to create zip file for dataset " + dataset_id, true)  
  end
def create_zip ( dataset_id , path_to_dipfiles ) ds = Dlibhydra :: Dataset . find ( dataset_id ) zip_dir = File . join ( ENV [ 'DIP_LOCATION' ] , "zips" , dataset_id ) zip_file = File . join ( zip_dir , "dataset.zip" ) FileUtils . mkdir_p ( zip_dir ) result = "" begin result = ` zip -rqj  #{ zip_file } #{ path_to_dipfiles }  2>&1 ` raise if ! result . empty? or ! $? . success? rescue => e handle_exception ( e , "Failed to create zip file for dataset " + dataset_id + ", output: " + result , "Failed to create zip file for dataset " + dataset_id + ", output: " + result , true ) end rescue => e handle_exception ( e , "Unable to create zip file for dataset " + dataset_id , "Unable to create zip file for dataset " + dataset_id , true ) end
create a zip file from a dip
create a zip file from a dip
# quick sanity check on input # create a folder for the zip file # get the OS to create the zip
dataset_id
<not_specific>
path_to_dipfiles
<not_specific>