From 9c61d174433a5556fc07c833d7350d91e276d096 Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Mon, 1 Jul 2024 10:22:28 +0300 Subject: [PATCH 01/11] - fix stop.sh script --- config/examples/docker-compose/stop.sh | 12 ++++++------ versions.md | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/config/examples/docker-compose/stop.sh b/config/examples/docker-compose/stop.sh index 20bd338..badfe92 100644 --- a/config/examples/docker-compose/stop.sh +++ b/config/examples/docker-compose/stop.sh @@ -1,27 +1,27 @@ #!/bin/bash stop_broker() { - /usr/bin/docker-compose -f /home/dima/media/docker-compose-broker.yml down --remove-orphans + /usr/bin/docker-compose -f /home/dima/media/docker-compose-broker.yml down } stop_media() { - /usr/bin/docker-compose -f /home/dima/media/docker-compose-media.yml down --remove-orphans + /usr/bin/docker-compose -f /home/dima/media/docker-compose-media.yml down } stop_bot() { - /usr/bin/docker-compose -f /home/dima/media/docker-compose-bot.yml down --remove-orphans + /usr/bin/docker-compose -f /home/dima/media/docker-compose-bot.yml down } stop_torrent() { - /usr/bin/docker-compose -f /home/dima/media/docker-compose-torrent.yml down --remove-orphans + /usr/bin/docker-compose -f /home/dima/media/docker-compose-torrent.yml down } stop_torrent_hdd() { - /usr/bin/docker-compose -f /home/dima/media/docker-compose-torrent-hdd.yml down --remove-orphans + /usr/bin/docker-compose -f /home/dima/media/docker-compose-torrent-hdd.yml down } stop_torrent_low() { - /usr/bin/docker-compose -f /home/dima/media/docker-compose-torrent-low.yml down --remove-orphans + /usr/bin/docker-compose -f /home/dima/media/docker-compose-torrent-low.yml down } keys_specified=false diff --git a/versions.md b/versions.md index 52178df..8b7492a 100644 --- a/versions.md +++ b/versions.md @@ -23,8 +23,10 @@ - fix access of unauthorized users ### 1.19.1 - change search, remove it from /list -### 1.19.2 (alpha/beta) +### 1.19.2 (alpha) - add /downloads command +### 1.19.3 (beta) +- fix stop.sh script ## 1.20 Planning (_TODO_) - fix error `build_core / build_core The 'save-state' command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/` - add life update of the last message From c7a641c7b15a44df443f778d61562482c2b190f8 Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Mon, 1 Jul 2024 11:54:40 +0300 Subject: [PATCH 02/11] - add free space display --- .../com/halushko/kinocat/core/Commands.java | 1 + .../com/halushko/kinocat/core/Queues.java | 1 + .../kinocat/file/CheckDiskFreeSpace.java | 50 +++++++++++++++++++ .../com/halushko/kinocat/file/Constants.java | 23 ++++++++- .../kinocat/file/DevicesProcessor.java | 32 ++++++++++++ .../kinocat/file/FoldersProcessor.java | 2 +- .../java/com/halushko/kinocat/file/Main.java | 1 + .../kinocat/file/PrintDestinations.java | 12 ++--- .../com/halushko/kinocat/text/Constants.java | 5 ++ 9 files changed, 117 insertions(+), 10 deletions(-) create mode 100644 file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java create mode 100644 file/src/main/java/com/halushko/kinocat/file/DevicesProcessor.java diff --git a/core/src/main/java/com/halushko/kinocat/core/Commands.java b/core/src/main/java/com/halushko/kinocat/core/Commands.java index 5b45990..1682136 100644 --- a/core/src/main/java/com/halushko/kinocat/core/Commands.java +++ b/core/src/main/java/com/halushko/kinocat/core/Commands.java @@ -23,5 +23,6 @@ interface Torrent { interface File { String SELECT_DESTINATION = "/start_"; + String SHOW_FREE_SPACE = "/space"; } } diff --git a/core/src/main/java/com/halushko/kinocat/core/Queues.java b/core/src/main/java/com/halushko/kinocat/core/Queues.java index d455bcf..eced973 100644 --- a/core/src/main/java/com/halushko/kinocat/core/Queues.java +++ b/core/src/main/java/com/halushko/kinocat/core/Queues.java @@ -31,5 +31,6 @@ interface Text { interface File { String CHOOSE_THE_DESTINATION = "FILE_CHOOSE_THE_DESTINATION"; String MOVE_TO_FOLDER = "FILE_MOVE_TO_FOLDER"; + String SHOW_FREE_SPACE = "FILE_SHOW_FREE_SPACE"; } } diff --git a/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java new file mode 100644 index 0000000..9e76ba3 --- /dev/null +++ b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java @@ -0,0 +1,50 @@ +package com.halushko.kinocat.file; + +import com.halushko.kinocat.core.Queues; +import com.halushko.kinocat.core.handlers.input.CliCommandExecutor; +import com.halushko.kinocat.core.rabbit.SmartJson; +import lombok.extern.slf4j.Slf4j; +import lombok.val; + +import java.util.List; + +@Slf4j +public class CheckDiskFreeSpace extends CliCommandExecutor { + @Override + 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()) { + 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*$", "") + ); + } + } + } + } + + return sb.toString(); + } + + @Override + protected String getQueue() { + return Queues.File.CHOOSE_THE_DESTINATION; + } + + @Override + protected String[] getScript(SmartJson rabbitMessage) { + return new String[]{ + "/usr/bin/df", + "-h" + }; + } +} diff --git a/file/src/main/java/com/halushko/kinocat/file/Constants.java b/file/src/main/java/com/halushko/kinocat/file/Constants.java index a57a491..47f7b25 100644 --- a/file/src/main/java/com/halushko/kinocat/file/Constants.java +++ b/file/src/main/java/com/halushko/kinocat/file/Constants.java @@ -9,8 +9,29 @@ public interface Constants { String EMPTY_SERVICE_DEFAULT_NAME = "main"; Map FOLDERS = new FoldersProcessor(System.getenv("TORRENT_IP")) .values.keySet().stream() - .collect(Collectors.toMap(key -> key, key -> String.format(PATH_TO_DESTINATION_FOLDER + "%s", !key.isEmpty() ? "_" + key : ""))); + .collect( + Collectors.toMap( + key -> key, + key -> String.format(PATH_TO_DESTINATION_FOLDER + "%s", !key.isEmpty() ? "_" + key : "") + ) + ); String NAME_LINE = "^\\s+Name:\\s+"; String SIZE_LINE = "^\\s+Total Size:\\s+"; + Map DEVICES = new DevicesProcessor(System.getenv("TORRENT_IP")) + .values.entrySet().stream() + .collect( + Collectors.toMap( + Map.Entry::getKey, + value -> value.getValue().get("folder") + ) + ) + .entrySet().stream() + .filter(x -> !x.getValue().isEmpty()) + .collect( + Collectors.toMap( + Map.Entry::getKey, + Map.Entry::getValue + ) + ); } diff --git a/file/src/main/java/com/halushko/kinocat/file/DevicesProcessor.java b/file/src/main/java/com/halushko/kinocat/file/DevicesProcessor.java new file mode 100644 index 0000000..223457d --- /dev/null +++ b/file/src/main/java/com/halushko/kinocat/file/DevicesProcessor.java @@ -0,0 +1,32 @@ +package com.halushko.kinocat.file; + +import com.halushko.kinocat.core.JsonConstants; +import com.halushko.kinocat.core.prcessors.ServicesInfoProcessor; +import com.halushko.kinocat.core.prcessors.ValueProcessor; + +import java.util.ArrayList; +import java.util.List; + +public class DevicesProcessor extends ServicesInfoProcessor { + + public DevicesProcessor(String json) { + super(json); + } + + @Override + public ValueProcessor getNameProcessor() { + return new ValueProcessor(JsonConstants.WebKeys.KEY_NAME, Constants.EMPTY_SERVICE_DEFAULT_NAME); + } + + @Override + public List getServiceProcessors() { + return new ArrayList<>() {{ + this.add(new ValueProcessor("folder", "")); + }}; + } + + @Override + public String getUrlTemplate() { + return ""; + } +} diff --git a/file/src/main/java/com/halushko/kinocat/file/FoldersProcessor.java b/file/src/main/java/com/halushko/kinocat/file/FoldersProcessor.java index a0dc56a..a82133f 100644 --- a/file/src/main/java/com/halushko/kinocat/file/FoldersProcessor.java +++ b/file/src/main/java/com/halushko/kinocat/file/FoldersProcessor.java @@ -15,7 +15,7 @@ public FoldersProcessor(String json) { @Override public ValueProcessor getNameProcessor() { - return new ValueProcessor(JsonConstants.WebKeys.KEY_NAME, ""); + return new ValueProcessor(JsonConstants.WebKeys.KEY_NAME, Constants.EMPTY_SERVICE_DEFAULT_NAME); } @Override diff --git a/file/src/main/java/com/halushko/kinocat/file/Main.java b/file/src/main/java/com/halushko/kinocat/file/Main.java index 2126a0c..3f8ea4f 100644 --- a/file/src/main/java/com/halushko/kinocat/file/Main.java +++ b/file/src/main/java/com/halushko/kinocat/file/Main.java @@ -7,5 +7,6 @@ public static void main(String[] args) { new UserMessageHandler().run(); new PrintDestinations().run(); new MoveToDestinationFolder().run(); + new CheckDiskFreeSpace().run(); } } \ No newline at end of file diff --git a/file/src/main/java/com/halushko/kinocat/file/PrintDestinations.java b/file/src/main/java/com/halushko/kinocat/file/PrintDestinations.java index eb58710..d45672c 100644 --- a/file/src/main/java/com/halushko/kinocat/file/PrintDestinations.java +++ b/file/src/main/java/com/halushko/kinocat/file/PrintDestinations.java @@ -14,7 +14,7 @@ public class PrintDestinations extends CliCommandExecutor { @Override protected String getResultString(List lines, SmartJson rabbitMessage) { - log.debug(String.format("[getResultString] [%s]", String.join(", ", lines))); + log.debug(String.format("[PrintDestinations] [%s]", String.join(", ", lines))); String[] result = new String[4]; result[0] = "("; result[2] = ") "; @@ -32,9 +32,9 @@ protected String getResultString(List lines, SmartJson rabbitMessage) { Constants.FOLDERS.keySet().stream() .map(folder -> String.format("\n%s: %s%s_%s", - getServiceLable(folder), + folder, Commands.File.SELECT_DESTINATION, - getServiceLable(folder), + folder, fileName ) ) @@ -42,13 +42,9 @@ protected String getResultString(List lines, SmartJson rabbitMessage) { ); } - private static String getServiceLable(String folder) { - return folder.isEmpty() ? Constants.EMPTY_SERVICE_DEFAULT_NAME : folder; - } - @Override protected String getQueue() { - return Queues.File.CHOOSE_THE_DESTINATION; + return Queues.File.SHOW_FREE_SPACE; } @Override diff --git a/text/src/main/java/com/halushko/kinocat/text/Constants.java b/text/src/main/java/com/halushko/kinocat/text/Constants.java index 232b9ce..dc1b4f1 100644 --- a/text/src/main/java/com/halushko/kinocat/text/Constants.java +++ b/text/src/main/java/com/halushko/kinocat/text/Constants.java @@ -86,5 +86,10 @@ public interface Constants { Queues.File.MOVE_TO_FOLDER, "<папка> <файл> обрати в яку папку буде завантаження" ); + + addValue(Commands.File.SHOW_FREE_SPACE, + Queues.File.SHOW_FREE_SPACE, + "відобразити вільне місце у сховищі" + ); }}; } From 76dd9a38d9f1496bf0db8c37b402eb351e321558 Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Mon, 1 Jul 2024 12:04:51 +0300 Subject: [PATCH 03/11] - add free space display --- .../halushko/kinocat/file/CheckDiskFreeSpace.java | 14 +++++++++++++- .../halushko/kinocat/file/PrintDestinations.java | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) 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 9e76ba3..9c3f3f8 100644 --- a/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java +++ b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java @@ -14,6 +14,18 @@ public class CheckDiskFreeSpace extends CliCommandExecutor { 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)) { @@ -37,7 +49,7 @@ protected String getResultString(List lines, SmartJson rabbitMessage) { @Override protected String getQueue() { - return Queues.File.CHOOSE_THE_DESTINATION; + return Queues.File.SHOW_FREE_SPACE; } @Override diff --git a/file/src/main/java/com/halushko/kinocat/file/PrintDestinations.java b/file/src/main/java/com/halushko/kinocat/file/PrintDestinations.java index d45672c..9423c67 100644 --- a/file/src/main/java/com/halushko/kinocat/file/PrintDestinations.java +++ b/file/src/main/java/com/halushko/kinocat/file/PrintDestinations.java @@ -44,7 +44,7 @@ protected String getResultString(List lines, SmartJson rabbitMessage) { @Override protected String getQueue() { - return Queues.File.SHOW_FREE_SPACE; + return Queues.File.CHOOSE_THE_DESTINATION; } @Override From 4eddab61f3b86431425e71458af1322b06d1e9ee Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Mon, 1 Jul 2024 12:10:52 +0300 Subject: [PATCH 04/11] - add free space display --- .../java/com/halushko/kinocat/file/CheckDiskFreeSpace.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 9c3f3f8..9274f38 100644 --- a/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java +++ b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java @@ -16,10 +16,10 @@ protected String getResultString(List lines, SmartJson rabbitMessage) { StringBuilder sb = new StringBuilder("Вільного місця у сховищі:"); for (val device : Constants.FOLDERS.entrySet()) { - sb.append("\nfolder ").append(device.getKey()).append(": ").append(device.getValue()); + 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()); + sb.append("\n device: ").append(device.getKey()).append(": ").append(device.getValue()); } for (String line : lines) { sb.append("\nres: ").append(line); @@ -55,7 +55,7 @@ protected String getQueue() { @Override protected String[] getScript(SmartJson rabbitMessage) { return new String[]{ - "/usr/bin/df", + "/bin/df", "-h" }; } From b9f0321f0400e6e933855353e5701ea900862a9f Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Mon, 1 Jul 2024 12:24:58 +0300 Subject: [PATCH 05/11] - 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(); From a43223123f9b68b4fe3f8c0a4c5dc6d58b6d1c5f Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Mon, 1 Jul 2024 18:48:41 +0300 Subject: [PATCH 06/11] - add free space display --- .../kinocat/file/CheckDiskFreeSpace.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) 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 351242c..0bb8185 100644 --- a/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java +++ b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java @@ -15,21 +15,27 @@ 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()) { + for (String line : lines) { + sb.append("\n").append(line); + } + + for (val device : Constants.FOLDERS.entrySet()) { boolean flag = false; + sb.append("\n").append(device.getKey()); 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*$", "") - ); + String size = line; + size = size.replaceAll("^\\S+\\s+\\S+\\s+\\S+\\s+", ""); + size = size.replaceAll("\\S+\\s+\\S+\\s*$", ""); + + sb.append("\n").append(device.getKey()); + sb.append(": ").append(size); + flag = true; + break; } } - if(!flag) { + if (!flag) { sb.append("\n").append(device.getKey()).append(": не вказано Filesystem у налаштуваннях"); } } From d3dd03063e88f22def9bae12f2c58c91ab56cd9d Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Wed, 3 Jul 2024 20:51:08 +0300 Subject: [PATCH 07/11] - add free space display --- .../kinocat/file/CheckDiskFreeSpace.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) 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 0bb8185..b208096 100644 --- a/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java +++ b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java @@ -12,30 +12,24 @@ public class CheckDiskFreeSpace extends CliCommandExecutor { @Override protected String getResultString(List lines, SmartJson rabbitMessage) { - log.debug(String.format("[CheckDiskFreeSpace] [%s]", String.join(", ", lines))); - StringBuilder sb = new StringBuilder("Вільного місця у сховищі:"); - - for (String line : lines) { - sb.append("\n").append(line); - } + log.debug(String.format("[CheckDiskFreeSpace] df -h result:\n[%s]", String.join("\n", lines))); + log.debug(String.format("[CheckDiskFreeSpace] folders:\n[%s]", String.join("\n", Constants.FOLDERS.keySet()))); + StringBuilder sb = new StringBuilder("Вільного місця у сховищі:"); for (val device : Constants.FOLDERS.entrySet()) { - boolean flag = false; - sb.append("\n").append(device.getKey()); + boolean storageIsFound = false; for (String line : lines) { if (line.matches(device.getKey() + ".*")) { - String size = line; - size = size.replaceAll("^\\S+\\s+\\S+\\s+\\S+\\s+", ""); - size = size.replaceAll("\\S+\\s+\\S+\\s*$", ""); - sb.append("\n").append(device.getKey()); - sb.append(": ").append(size); + sb.append(": ").append(getSize(line)); - flag = true; + log.debug(String.format("[CheckDiskFreeSpace] Folder [%s] is present in line [%s]", device.getKey(), line)); + storageIsFound = true; break; } + log.debug(String.format("[CheckDiskFreeSpace] Folder [%s] is NOT present in line [%s]", device.getKey(), line)); } - if (!flag) { + if (!storageIsFound) { sb.append("\n").append(device.getKey()).append(": не вказано Filesystem у налаштуваннях"); } } @@ -43,6 +37,13 @@ protected String getResultString(List lines, SmartJson rabbitMessage) { return sb.toString(); } + private static String getSize(String line) { + String size = line; + size = size.replaceAll("^\\S+\\s+\\S+\\s+\\S+\\s+", ""); + size = size.replaceAll("\\S+\\s+\\S+\\s*$", ""); + return size; + } + @Override protected String getQueue() { return Queues.File.SHOW_FREE_SPACE; From 9524a0ef11f714a52962c22231a56efb52f8f2c0 Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Sun, 7 Jul 2024 13:07:07 +0300 Subject: [PATCH 08/11] - add free space display --- .../java/com/halushko/kinocat/file/CheckDiskFreeSpace.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 b208096..7db1ab3 100644 --- a/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java +++ b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java @@ -16,10 +16,10 @@ protected String getResultString(List lines, SmartJson rabbitMessage) { log.debug(String.format("[CheckDiskFreeSpace] folders:\n[%s]", String.join("\n", Constants.FOLDERS.keySet()))); StringBuilder sb = new StringBuilder("Вільного місця у сховищі:"); - for (val device : Constants.FOLDERS.entrySet()) { + for (val device : Constants.DEVICES.entrySet()) { boolean storageIsFound = false; for (String line : lines) { - if (line.matches(device.getKey() + ".*")) { + if (line.matches(device.getValue() + ".*")) { sb.append("\n").append(device.getKey()); sb.append(": ").append(getSize(line)); From ee78f70b6a0406ebe8bf491ada78c536d727f8e9 Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Sun, 7 Jul 2024 13:07:17 +0300 Subject: [PATCH 09/11] - add free space display --- .../main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7db1ab3..4ab45b8 100644 --- a/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java +++ b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java @@ -13,7 +13,7 @@ public class CheckDiskFreeSpace extends CliCommandExecutor { @Override protected String getResultString(List lines, SmartJson rabbitMessage) { log.debug(String.format("[CheckDiskFreeSpace] df -h result:\n[%s]", String.join("\n", lines))); - log.debug(String.format("[CheckDiskFreeSpace] folders:\n[%s]", String.join("\n", Constants.FOLDERS.keySet()))); + log.debug(String.format("[CheckDiskFreeSpace] folders:\n[%s]", String.join("\n", Constants.DEVICES.keySet()))); StringBuilder sb = new StringBuilder("Вільного місця у сховищі:"); for (val device : Constants.DEVICES.entrySet()) { From 3c5961ee904c2070415a6f60fc4f16698c29478f Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Sun, 7 Jul 2024 13:08:06 +0300 Subject: [PATCH 10/11] - add free space display --- .../java/com/halushko/kinocat/file/CheckDiskFreeSpace.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 4ab45b8..dc95d71 100644 --- a/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java +++ b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java @@ -13,7 +13,8 @@ public class CheckDiskFreeSpace extends CliCommandExecutor { @Override protected String getResultString(List lines, SmartJson rabbitMessage) { log.debug(String.format("[CheckDiskFreeSpace] df -h result:\n[%s]", String.join("\n", lines))); - log.debug(String.format("[CheckDiskFreeSpace] folders:\n[%s]", String.join("\n", Constants.DEVICES.keySet()))); + log.debug(String.format("[CheckDiskFreeSpace] names:\n[%s]", String.join("\n", Constants.DEVICES.keySet()))); + log.debug(String.format("[CheckDiskFreeSpace] devices:\n[%s]", String.join("\n", Constants.DEVICES.keySet()))); StringBuilder sb = new StringBuilder("Вільного місця у сховищі:"); for (val device : Constants.DEVICES.entrySet()) { From f8ea8d4ce7d437f074d91eace8faec63a4e52a71 Mon Sep 17 00:00:00 2001 From: Dmytro Galushko Date: Sun, 7 Jul 2024 13:08:17 +0300 Subject: [PATCH 11/11] - add free space display --- .../main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 dc95d71..b2b22c7 100644 --- a/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java +++ b/file/src/main/java/com/halushko/kinocat/file/CheckDiskFreeSpace.java @@ -14,7 +14,7 @@ public class CheckDiskFreeSpace extends CliCommandExecutor { protected String getResultString(List lines, SmartJson rabbitMessage) { log.debug(String.format("[CheckDiskFreeSpace] df -h result:\n[%s]", String.join("\n", lines))); log.debug(String.format("[CheckDiskFreeSpace] names:\n[%s]", String.join("\n", Constants.DEVICES.keySet()))); - log.debug(String.format("[CheckDiskFreeSpace] devices:\n[%s]", String.join("\n", Constants.DEVICES.keySet()))); + log.debug(String.format("[CheckDiskFreeSpace] devices:\n[%s]", String.join("\n", Constants.DEVICES.values()))); StringBuilder sb = new StringBuilder("Вільного місця у сховищі:"); for (val device : Constants.DEVICES.entrySet()) {