snowplow-archive / sluice

A Ruby toolkit for cloud-friendly ETL
38 stars 10 forks source link

Add exists? and fix is_file? and is_folder? #29

Open alexanderdean opened 10 years ago

alexanderdean commented 10 years ago

There's no exists? currently, and is_file? and is_folder? don't check for existence first.

alexanderdean commented 10 years ago

Here's an impl:

      # Check if a file exists in a given directory
      Contract String, String => Bool
      def file_exists?(s3, directory, file)
        loc = Sluice::Storage::S3::Location.new(directory)
        dir = s3.directories.get(loc.bucket, prefix: loc.dir_as_path)
        (not dir.files.head(loc.dir_as_path + file).nil?)
      end