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. 8
      airsonic-main/src/main/java/org/airsonic/player/controller/InternalHelpController.java
  2. 5
      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);
} }
if (environment.acceptsProfiles("legacy")) {
map.put("dbIsLegacy", true);
File dbDirectory = new File(settingsService.getAirsonicHome(), "db"); File dbDirectory = new File(settingsService.getAirsonicHome(), "db");
map.put("dbDirectorySizeBytes", dbDirectory.exists() ? FileUtils.sizeOfDirectory(dbDirectory) : 0); map.put("dbDirectorySizeBytes", dbDirectory.exists() ? FileUtils.sizeOfDirectory(dbDirectory) : 0);
map.put("dbDirectorySize", FileUtils.byteCountToDisplaySize((long) map.get("dbDirectorySizeBytes"))); map.put("dbDirectorySize", FileUtils.byteCountToDisplaySize((long) map.get("dbDirectorySizeBytes")));
File dbLogFile = new File(dbDirectory, "airsonic.log"); File dbLogFile = new File(dbDirectory, "airsonic.log");
map.put("dbLogSizeBytes", dbLogFile.exists() ? dbLogFile.length() : 0); map.put("dbLogSizeBytes", dbLogFile.exists() ? dbLogFile.length() : 0);
map.put("dbLogSize", FileUtils.byteCountToDisplaySize((long) map.get("dbLogSizeBytes"))); 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,6 +82,7 @@
<table width="75%" class="ruleTable indent"> <table width="75%" class="ruleTable indent">
<c:if test="${model.dbIsLegacy}">
<tr> <tr>
<td colspan="2" class="ruleTableCell"> <td colspan="2" class="ruleTableCell">
<c:choose> <c:choose>
@ -96,11 +97,15 @@
</c:choose> </c:choose>
</td> </td>
</tr> </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>
<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.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> <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