From 09fa486bb04b5d4ad49ec4ba9e46aca0cf3ae4fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Thomas?= Date: Tue, 11 Feb 2020 21:43:13 +0100 Subject: [PATCH] Internal help: Only show db filesystem size for legacy profile --- .../controller/InternalHelpController.java | 20 +++++++--- .../main/webapp/WEB-INF/jsp/internalhelp.jsp | 37 +++++++++++-------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/airsonic-main/src/main/java/org/airsonic/player/controller/InternalHelpController.java b/airsonic-main/src/main/java/org/airsonic/player/controller/InternalHelpController.java index 0bf9dcb4..0f9b5233 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/controller/InternalHelpController.java +++ b/airsonic-main/src/main/java/org/airsonic/player/controller/InternalHelpController.java @@ -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)); diff --git a/airsonic-main/src/main/webapp/WEB-INF/jsp/internalhelp.jsp b/airsonic-main/src/main/webapp/WEB-INF/jsp/internalhelp.jsp index 3d5c39a5..350a16d8 100644 --- a/airsonic-main/src/main/webapp/WEB-INF/jsp/internalhelp.jsp +++ b/airsonic-main/src/main/webapp/WEB-INF/jsp/internalhelp.jsp @@ -82,25 +82,30 @@ - - - + + + + + - - + + + + +
- - - OK - - - - Warning - - - -
+ + + OK + + + + Warning + + + +
${model.dbDriverName}
${model.dbDriverVersion}
${model.dbDirectorySize}
${model.dbLogSize}
${model.dbDirectorySize}
${model.dbLogSize}