Method: FileMonitoring::DirStat#handle_existing_file

Defined in:
lib/file_monitoring/monitor_path.rb

#handle_existing_file(child_stat, globed_path, globed_path_stat) ⇒ Object



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/file_monitoring/monitor_path.rb', line 336

def handle_existing_file(child_stat, globed_path, globed_path_stat)
  if child_stat.changed?(globed_path_stat)
    # ---------- STATUS CHANGED
    # Update changed status
    child_stat.state = FileStatEnum::CHANGED
    child_stat.cycles = 0
    child_stat.size = globed_path_stat.size
    child_stat.modification_time = globed_path_stat.mtime.to_i
    write_to_log("CHANGED file: " + globed_path)
    # remove file with changed checksum. File will be added once indexed
    $local_content_data_lock.synchronize{
      $local_content_data.remove_instance(Params['local_server_name'], globed_path)
    }
  else  # case child_stat did not change
    # ---------- SAME STATUS
    # File status is the same
    if child_stat.state != FileStatEnum::STABLE
      child_stat.cycles += 1
      if child_stat.cycles >= ::FileMonitoring.stable_state
        child_stat.state = FileStatEnum::STABLE
        write_to_log("STABLE file: " + globed_path)
      else
        child_stat.state = FileStatEnum::UNCHANGED
        write_to_log("UNCHANGED file: " + globed_path)
      end
    end
  end
end