Skip to content

Commit 0e1bc1a

Browse files
author
David Zuckerman
committed
Making sure LBNL file was not already processed before downloading
1 parent 7a3d3ba commit 0e1bc1a

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

lib/berkeley_library/sftp_handler/downloader/base.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ def ssh_options
4141
end
4242
end
4343

44+
def assert_file_not_processed!(processed_path)
45+
raise "File was already processed: #{processed_path}" \
46+
if Pathname.new(processed_path).exist?
47+
end
48+
4449
def assert_not_exists!(local_path)
4550
raise "Local file already exists: #{local_path}" \
4651
if Pathname.new(local_path).exist?

lib/berkeley_library/sftp_handler/downloader/lbnl.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def download!(filename: nil, local_dir: '/opt/app/data')
1515
filename ||= default_filename
1616
remote_path = Pathname.new(filename)
1717
local_path = Pathname.new(local_dir) + filename
18+
assert_file_not_processed! local_path + '.old'
1819
assert_not_exists! local_path
1920

2021
connect do |sftp|

0 commit comments

Comments
 (0)