def __refresh_pending_files(self, current_time):
        """Check to see if __pending_files needs to be adjusted due to log rotation or the
        current log growing.

        This should be called periodically to sync the state of the file system with the metadata
        tracked by this abstraction.

        @param current_time: If not None, the value to use for the current_time.  Used for testing purposes.
        @type current_time: float or None
        """

        has_no_position = len(self.__pending_files) == 0

        # Check to see if the last file in our pending files is still at the path of the real log file.
        if len(self.__pending_files) > 0 and self.__pending_files[-1].is_log_file:
            current_log_file = self.__pending_files[-1]
        else:
            current_log_file = None

        # First, try to see if the file at the log file path still exists, and if so, what's size and inode is.
        try:
            # Get the latest size and inode of the file at __path.
            stat_result = self.__file_system.stat(self.__path)
            latest_inode = stat_result.st_ino
            latest_size = stat_result.st_size
            self.__modification_time = datetime.datetime.fromtimestamp(stat_result.st_mtime)

            # See if it is rotated by checking out the file handle we last opened to this file path.
            if current_log_file is not None:
                if (current_log_file.last_known_size > latest_size or
                        self.__file_system.trust_inodes and current_log_file.inode != latest_inode):
                    # Ok, the log file has rotated.  We need to add in a new entry to represent this.
                    # But, we also take this opportunity to see if the current entry we had for the log file has
                    # grown in length since the last time we checked it, which is possible.  This is the last time
                    # we have to check it since theorectically, the file would have been fully rotated before a new
                    # log file was created to take its place.
                    if current_log_file.file_handle is not None:
                        current_log_file.last_known_size = max(
                            current_log_file.last_known_size,
                            self.__file_system.get_file_size(current_log_file.file_handle))
                    elif not self.__file_system.trust_inodes:
                        # If we do not have the file handle open (probably because we are on a win32 system) and
                        # we do not trust inodes, then there is no way to get back to the original contents, so we
                        # just mark this file portion as now invalid.
                        current_log_file.valid = False
                    current_log_file.is_log_file = False
                    current_log_file.position_end = current_log_file.position_start + current_log_file.last_known_size
                    # Note, we do not yet detect if current_log_file is actually pointing to the same inode as the
                    # log_path.  This could be true if the log file was copied to another location and then truncated
                    # in place (a commom mode of operation used by logrotate).  If this is the case, then the
                    # file_handle in current_log_file will eventually fail since it will seek to a location no longer
                    # in the file.  We handle that fairly cleanly in __fill_buffer so no need to do it here.  However,
                    # if we want to look for the file where the previous log file was copied, this is where we would
                    # do it.  That is a future feature.

                    # Add in an entry for the file content at log_path.
                    self.__add_entry_for_log_path(latest_inode)
                else:
                    # It has not been rotated.  So we just update the size of the current entry.
                    current_log_file.last_known_size = latest_size
                    current_log_file.position_end = current_log_file.position_start + latest_size
            else:
                # There is no entry representing the file at log_path, but it does exist, so we need to add it in.
                self.__add_entry_for_log_path(latest_inode)
        except __HOLE__, e:
            # The file could have disappeared or the file permissions could have changed such that we can no longer
            # read it.  We have to handle these cases gracefully.  We treat both like it has disappeared from our point
            # of view.
            if e.errno == errno.ENOENT or e.errno == errno.EACCES:
                # The file doesn't exist.  See if we think we have a file handle that is for the log path, and if
                # so, update it to reflect it no longer is.
                if current_log_file is not None:
                    current_log_file.is_log_file = False
                    if current_log_file.file_handle is not None:
                        current_log_file.last_known_size = max(current_log_file.last_known_size,
                                                               self.__file_system.get_file_size(
                                                                   current_log_file.file_handle))
                    current_log_file.position_end = current_log_file.position_start + current_log_file.last_known_size
                if self.__log_deletion_time is None:
                    self.__log_deletion_time = current_time
                self.at_end = current_time - self.__log_deletion_time > self.__log_deletion_delay

            else:
                raise

        if has_no_position and len(self.__pending_files) > 0:
            self.__position = self.__pending_files[-1].position_end
dataset/ETHPy150Open scalyr/scalyr-agent-2/scalyr_agent/log_processing.py/LogFileIterator.__refresh_pending_files