From b9f0321f0400e6e933855353e5701ea900862a9f Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Mon, 1 Jul 2024 12:24:58 +0300 Subject: [PATCH] - add free space display --- .../docker-compose/docker-compose-bot.yml | 1 + .../kinocat/file/CheckDiskFreeSpace.java | 40 +++++++------------ 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/config/examples/docker-compose/docker-compose-bot.yml b/config/examples/docker-compose/docker-compose-bot.yml index fdba88e..397b87e 100644 --- a/config/examples/docker-compose/docker-compose-bot.yml +++ b/config/examples/docker-compose/docker-compose-bot.yml @@ -45,6 +45,7 @@ services: - ./workdir/config/files_from_telegram_hdd:/home/torrent_files_hdd/ - ./workdir/config/files_from_telegram_low:/home/torrent_files_low/ - ./workdir/config/logs:/home/app/logs + - ./workdir/mediadata_hdd/mediadata:/home/app/tmp1 networks: bot_network_local: networks: diff --git a/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java index 9274f38..351242c 100644 --- a/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java +++ b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java @@ -15,33 +15,23 @@ protected String getResultString(List lines, SmartJson rabbitMessage) { log.debug(String.format("[CheckDiskFreeSpace] [%s]", String.join(", ", lines))); StringBuilder sb = new StringBuilder("Вільного місця у сховищі:"); - for (val device : Constants.FOLDERS.entrySet()) { - sb.append("\nfolder: ").append(device.getKey()).append(": ").append(device.getValue()); - } - for (val device : Constants.DEVICES.entrySet()) { - sb.append("\n device: ").append(device.getKey()).append(": ").append(device.getValue()); - } - for (String line : lines) { - sb.append("\nres: ").append(line); - } - - - for (val device : Constants.FOLDERS.entrySet()) { - val key = device.getKey(); - if (Constants.DEVICES.containsKey(key)) { - val value = Constants.DEVICES.get(key); - for (String line : lines) { - if (line.matches(value + ".*")) { - sb.append("\n") - .append(key) - .append(": ") - .append( - line.replaceAll("^\\S+\\s+\\S+\\s+\\S+\\s+", "") - .replaceAll("\\S+\\s+\\S+\\s*$", "") - ); - } +for (val device : Constants.FOLDERS.entrySet()) { + boolean flag = false; + for (String line : lines) { + if (line.matches(device.getKey() + ".*")) { + sb.append("\n") + .append(device.getKey()) + .append(": ") + .append( + line.replaceAll("^\\S+\\s+\\S+\\s+\\S+\\s+", "") + .replaceAll("\\S+\\s+\\S+\\s*$", "") + ); + flag = true; } } + if(!flag) { + sb.append("\n").append(device.getKey()).append(": не вказано Filesystem у налаштуваннях"); + } } return sb.toString();