def _ensure_file_is_good(self, current_time):
if self._last_file_mapping_update and current_time - self._last_file_mapping_update <= self._stat_interval:<EOL><INDENT>return<EOL><DEDENT>self._last_file_mapping_update = time.time()<EOL>try:<EOL><INDENT>st = os.stat(self._filename)<EOL><DEDENT>except EnvironmentError as err:<EOL><INDENT>if err.errno == errno.ENOENT:<EOL><INDENT>self._log_info('<STR_LIT>')<EOL>self.close()<EOL>return<EOL><DEDENT>raise<EOL><DEDENT>fid = self.get_file_id(st)<EOL>if fid != self._fid:<EOL><INDENT>self._log_info('<STR_LIT>')<EOL>self.close()<EOL><DEDENT>elif self._file.tell() > st.st_size:<EOL><INDENT>if st.st_size == <NUM_LIT:0> and self._ignore_truncate:<EOL><INDENT>self._logger.info("<STR_LIT>".format(fid, self._filename) +<EOL>"<STR_LIT>" +<EOL>"<STR_LIT>" +<EOL>"<STR_LIT>" +<EOL>"<STR_LIT>")<EOL>return<EOL><DEDENT>self._log_info('<STR_LIT>')<EOL>self._update_file(seek_to_end=False)<EOL><DEDENT>elif REOPEN_FILES:<EOL><INDENT>self._log_debug('<STR_LIT>')<EOL>position = self._file.tell()<EOL>self._update_file(seek_to_end=False)<EOL>if self.active:<EOL><INDENT>self._file.seek(position, os.SEEK_SET)<EOL><DEDENT><DEDENT>
Every N seconds, ensures that the file we are tailing is the file we expect to be tailing