Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Latest matchlog is being deleted instead of old ones by RobotLog #673

Open
@ftc-team-astro-bruins

Description

Below function pruneMatchLogsIfNecessary, even though the author is wanting to delete the old logs the code actually deletes the latest logs. You can test this by creating 5 or more logs and see that after 5 logs are created it always deleted the latest log instead of the old one. I could not find the repo of FTC SDK, if you could point me to the original FTC SDK repo i can send you in the required change.
/*

  • pruneMatchLogsIfNecessary
  • Some reasonable upper bound on number of files to keep around. Remove via first in, first out.
    */
    protected static void pruneMatchLogsIfNecessary() {
    File directory = AppUtil.MATCH_LOG_FOLDER;
    File[] files = directory.listFiles();
if (files.length >= AppUtil.MAX_MATCH_LOGS_TO_KEEP) {
  Arrays.sort(files, new Comparator<File>() {
    public int compare(File f1, File f2) {
      /*
       * Reverse sorting on purpose.
       */
      return Long.compare(f2.lastModified(), f1.lastModified());
    }
  });

  /*
   * There should never be more than one extra log, but just to be paranoid...
   */
  for (int i = 0; i < files.length - AppUtil.MAX_MATCH_LOGS_TO_KEEP; i++) {
    RobotLog.ii(TAG, "Pruning old logs deleting " + files[i].getName());
    files[i].delete();
  }
}

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions