Internal help: Only show db filesystem size for legacy profile

master
François-Xavier Thomas 5 years ago committed by jvoisin
parent 50b6da075e
commit 09fa486bb0
  1. 20
      airsonic-main/src/main/java/org/airsonic/player/controller/InternalHelpController.java
  2. 37
      airsonic-main/src/main/webapp/WEB-INF/jsp/internalhelp.jsp

@ -38,6 +38,7 @@ import org.apache.lucene.index.IndexReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -197,6 +198,8 @@ public class InternalHelpController {
private MediaFileDao mediaFileDao;
@Autowired
private TranscodingService transcodingService;
@Autowired
private Environment environment;
@GetMapping
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
@ -319,12 +322,17 @@ public class InternalHelpController {
LOG.debug("Unable to gather information", e);
}
File dbDirectory = new File(settingsService.getAirsonicHome(), "db");
map.put("dbDirectorySizeBytes", dbDirectory.exists() ? FileUtils.sizeOfDirectory(dbDirectory) : 0);
map.put("dbDirectorySize", FileUtils.byteCountToDisplaySize((long) map.get("dbDirectorySizeBytes")));
File dbLogFile = new File(dbDirectory, "airsonic.log");
map.put("dbLogSizeBytes", dbLogFile.exists() ? dbLogFile.length() : 0);
map.put("dbLogSize", FileUtils.byteCountToDisplaySize((long) map.get("dbLogSizeBytes")));
if (environment.acceptsProfiles("legacy")) {
map.put("dbIsLegacy", true);
File dbDirectory = new File(settingsService.getAirsonicHome(), "db");
map.put("dbDirectorySizeBytes", dbDirectory.exists() ? FileUtils.sizeOfDirectory(dbDirectory) : 0);
map.put("dbDirectorySize", FileUtils.byteCountToDisplaySize((long) map.get("dbDirectorySizeBytes")));
File dbLogFile = new File(dbDirectory, "airsonic.log");
map.put("dbLogSizeBytes", dbLogFile.exists() ? dbLogFile.length() : 0);
map.put("dbLogSize", FileUtils.byteCountToDisplaySize((long) map.get("dbLogSizeBytes")));
} else {
map.put("dbIsLegacy", false);
}
map.put("dbMediaFileMusicNonPresentCount", daoHelper.getJdbcTemplate().queryForObject(String.format("SELECT count(*) FROM MEDIA_FILE WHERE NOT present AND type = 'MUSIC'"), Long.class));
map.put("dbMediaFilePodcastNonPresentCount", daoHelper.getJdbcTemplate().queryForObject(String.format("SELECT count(*) FROM MEDIA_FILE WHERE NOT present AND type = 'PODCAST'"), Long.class));

@ -82,25 +82,30 @@
<table width="75%" class="ruleTable indent">
<tr>
<td colspan="2" class="ruleTableCell">
<c:choose>
<c:when test="${model.dbLogSizeBytes < 268435456}">
<img src="<spring:theme code='checkImage'/>" alt="OK">
<fmt:message key="internalhelp.dblogsize.ok"/>
</c:when>
<c:otherwise>
<img src="<spring:theme code='alertImage'/>" alt="Warning">
<fmt:message key="internalhelp.dblogsize.warn"/>
</c:otherwise>
</c:choose>
</td>
</tr>
<c:if test="${model.dbIsLegacy}">
<tr>
<td colspan="2" class="ruleTableCell">
<c:choose>
<c:when test="${model.dbLogSizeBytes < 268435456}">
<img src="<spring:theme code='checkImage'/>" alt="OK">
<fmt:message key="internalhelp.dblogsize.ok"/>
</c:when>
<c:otherwise>
<img src="<spring:theme code='alertImage'/>" alt="Warning">
<fmt:message key="internalhelp.dblogsize.warn"/>
</c:otherwise>
</c:choose>
</td>
</tr>
</c:if>
<tr><td class="ruleTableHeader"><fmt:message key="internalhelp.dbdrivername"/></td><td class="ruleTableCell">${model.dbDriverName}</td></tr>
<tr><td class="ruleTableHeader"><fmt:message key="internalhelp.dbdriverversion"/></td><td class="ruleTableCell">${model.dbDriverVersion}</td></tr>
<tr><td class="ruleTableHeader"><fmt:message key="internalhelp.dbdirectorysize"/></td><td class="ruleTableCell">${model.dbDirectorySize}</td></tr>
<tr><td class="ruleTableHeader"><fmt:message key="internalhelp.dblogsize"/></td><td class="ruleTableCell">${model.dbLogSize}</td></tr>
<c:if test="${model.dbIsLegacy}">
<tr><td class="ruleTableHeader"><fmt:message key="internalhelp.dbdirectorysize"/></td><td class="ruleTableCell">${model.dbDirectorySize}</td></tr>
<tr><td class="ruleTableHeader"><fmt:message key="internalhelp.dblogsize"/></td><td class="ruleTableCell">${model.dbLogSize}</td></tr>
</c:if>
<tr>
<td colspan="2" class="ruleTableCell">

Loading…
Cancel
Save