Method: FileMonitoring::DirStat#handle_moved_file

Defined in:
lib/file_monitoring/monitor_path.rb

#handle_moved_file(globed_path, globed_path_stat, file_attr_to_checksum) ⇒ Object

This method handles the case where we set the ‘manual_file_changes’ param meaning some files were moved/copied and no need to reindex them. In that case search “new files” in old files to get the checksum (skipp the index phase). The lookup is done via specially prepared file_attr_to_checksum map.



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/file_monitoring/monitor_path.rb', line 369

def handle_moved_file(globed_path, globed_path_stat, file_attr_to_checksum)
  # --------------------- MANUAL MODE
  # check if file name and attributes exist in global file attr map
  file_attr_key = [File.basename(globed_path), globed_path_stat.size, globed_path_stat.mtime.to_i]
  file_ident_info = file_attr_to_checksum[file_attr_key]
  # If not found (real new file) or found but not unique then file needs indexing. skip in manual mode.
  if file_ident_info && file_ident_info.unique
    Log.debug1("update content data with file:%s  checksum:%s  index_time:%s",
               File.basename(globed_path), file_ident_info.checksum, file_ident_info.index_time.to_s)
    # update content data (no need to update Dir tree)
    $local_content_data_lock.synchronize{
      $local_content_data.add_instance(file_ident_info.checksum,
                                       globed_path_stat.size,
                                       Params['local_server_name'],
                                       globed_path,
                                       globed_path_stat.mtime.to_i,
                                       file_ident_info.index_time)
    }
  end
end