in ideaSupport/src/main/scala/org/jetbrains/sbtidea/download/cachesCleanup/OldDownloadsCleanup.scala [35:64]
private def detectOldDownloadsAndRemoveIfNeeded(
report: DownloadsReport,
autoRemove: Boolean
): Unit = {
val oldDownloads = OldDownloadsDetector.detectOldDownloads(report)
if (oldDownloads.isEmpty) {
log.debug("No old cached downloads found for cleanup")
return
}
val totalSizeBytes = oldDownloads.map(_.path).map(FileUtils.getFileSize).sum
val totalSizeFormatted = CleanupUtils.formatSize(totalSizeBytes)
val filesCount = oldDownloads.length
val warningMessage =
s"""Detected $filesCount old cached download files (older than 1 month) in ${report.baseDirectory.toAbsolutePath}
|Total size: $totalSizeFormatted
|""".stripMargin.trim
log.warn(warningMessage)
if (autoRemove) {
log.warn(s"Removing old cached download files... (`$SbtKeyName` is enabled)")
removeOldDownloads(oldDownloads)
log.info(s"Successfully removed $filesCount old cached download files, freed $totalSizeFormatted of disk space")
} else {
log.warn(s"To automatically remove these files, set '$SbtKeyName := true' in your build.sbt")
}
}