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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -197,6 +198,8 @@ public class InternalHelpController {
private MediaFileDao mediaFileDao; private MediaFileDao mediaFileDao;
@Autowired @Autowired
private TranscodingService transcodingService; private TranscodingService transcodingService;
@Autowired
private Environment environment;
@GetMapping @GetMapping
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
@ -319,12 +322,17 @@ public class InternalHelpController {
LOG.debug("Unable to gather information", e); LOG.debug("Unable to gather information", e);
} }
File dbDirectory = new File(settingsService.getAirsonicHome(), "db"); if (environment.acceptsProfiles("legacy")) {
map.put("dbDirectorySizeBytes", dbDirectory.exists() ? FileUtils.sizeOfDirectory(dbDirectory) : 0); map.put("dbIsLegacy", true);
map.put("dbDirectorySize", FileUtils.byteCountToDisplaySize((long) map.get("dbDirectorySizeBytes"))); File dbDirectory = new File(settingsService.getAirsonicHome(), "db");
File dbLogFile = new File(dbDirectory, "airsonic.log"); map.put("dbDirectorySizeBytes", dbDirectory.exists() ? FileUtils.sizeOfDirectory(dbDirectory) : 0);
map.put("dbLogSizeBytes", dbLogFile.exists() ? dbLogFile.length() : 0); map.put("dbDirectorySize", FileUtils.byteCountToDisplaySize((long) map.get("dbDirectorySizeBytes")));
map.put("dbLogSize", FileUtils.byteCountToDisplaySize((long) map.get("dbLogSizeBytes"))); 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("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)); 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"> <table width="75%" class="ruleTable indent">
<tr> <c:if test="${model.dbIsLegacy}">
<td colspan="2" class="ruleTableCell"> <tr>
<c:choose> <td colspan="2" class="ruleTableCell">
<c:when test="${model.dbLogSizeBytes < 268435456}"> <c:choose>
<img src="<spring:theme code='checkImage'/>" alt="OK"> <c:when test="${model.dbLogSizeBytes < 268435456}">
<fmt:message key="internalhelp.dblogsize.ok"/> <img src="<spring:theme code='checkImage'/>" alt="OK">
</c:when> <fmt:message key="internalhelp.dblogsize.ok"/>
<c:otherwise> </c:when>
<img src="<spring:theme code='alertImage'/>" alt="Warning"> <c:otherwise>
<fmt:message key="internalhelp.dblogsize.warn"/> <img src="<spring:theme code='alertImage'/>" alt="Warning">
</c:otherwise> <fmt:message key="internalhelp.dblogsize.warn"/>
</c:choose> </c:otherwise>
</td> </c:choose>
</tr> </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.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.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> <tr>
<td colspan="2" class="ruleTableCell"> <td colspan="2" class="ruleTableCell">

Loading…
Cancel
Save