lib/daengine/digital_asset_processor.rb in daengine-0.2.19 vs lib/daengine/digital_asset_processor.rb in daengine-0.3

- old
+ new

@@ -45,12 +45,14 @@ def self.process_tuple_directory path = Daengine.config[:assets_path] raise "ERROR: DigitalAssetProcessor: Invalid assets_path provided. Unable to read from #{path}" unless File::directory?(path) # read the given directory, process each file in date order starting 2 days ago if last_read_time is nil time = self.read_last_process_time + last_run_time = 10.years.ago if not time.blank? @@last_read_time = time + last_run_time = time end Daengine.log("DigitalAssetProcessor: Last process time was #{@@last_read_time}", "info") deploy_files= [] deploy_files = Dir.entries(path).select { @@ -64,11 +66,11 @@ deploy_files.each do |filename| #parse the file and add metadata content to database. file = File.expand_path(filename, path) Daengine.log("DigitalAssetProcessor: Processing file #{filename} --- #{File.mtime(file)}", "info") open_file = File.open(file, 'rb') - Daengine::TeamsiteMetadataParser.parse_tuple_file(open_file) + Daengine::TeamsiteMetadataParser.parse_tuple_file(open_file, last_run_time) Daengine.log("DigitalAssetProcessor: Finished processing #{filename}", "info") @@last_read_time = File.mtime(file) + 1.second self.save_last_read_time Daengine.log("DigitalAssetProcessor: Last process time set to #{@@last_read_time}", "info") end @@ -86,16 +88,16 @@ Daengine.log("ERROR: DigitalAssetProcessor: Failed to write to #{target}.", "error") end end def self.read_last_process_time - time = "" + time = 1.year.ago begin target = Daengine.config[:daengine_yml_file] property = YAML.load_file(target) time = property['last_read_time'] rescue Exception => e - Daengine.log("ERROR: DigitalAssetProcessor: Failed to read from #{target}", "error") + Daengine.log("ERROR: DigitalAssetProcessor: Failed to read from #{target} - #{e.message}", "error") end time end end \ No newline at end of file