Method: FileMonitoring::FileStat#index

Defined in:
lib/file_monitoring/monitor_path.rb

#indexObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/file_monitoring/monitor_path.rb', line 90

def index
  if !@indexed and FileStatEnum::STABLE == @state
    #index file
    @@digest.reset
    begin
      File.open(@path, 'rb') { |f|
        while buffer = f.read(16384) do
          @@digest << buffer
        end
      }
      $local_content_data_lock.synchronize{
        $local_content_data.add_instance(@@digest.hexdigest.downcase, @size, Params['local_server_name'],
                                         @path, @modification_time)
      }
      #$process_vars.inc('indexed_files')
      $indexed_file_count += 1
      @indexed = true
    rescue
      Log.warning("Indexed path'#{@path}' does not exist. Probably file changed") if @@log
    end
  end
end