diff options
-rw-r--r-- | src/main/java/org/traccar/helper/Log.java | 27 | ||||
-rw-r--r-- | src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java | 3 |
2 files changed, 20 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/helper/Log.java b/src/main/java/org/traccar/helper/Log.java index 9aaf1cfd3..6c6d49550 100644 --- a/src/main/java/org/traccar/helper/Log.java +++ b/src/main/java/org/traccar/helper/Log.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2020 Anton Tananaev (anton@traccar.org) + * Copyright 2012 - 2024 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.traccar.helper; import org.traccar.config.Config; import org.traccar.config.Keys; +import org.traccar.model.Pair; import java.io.BufferedWriter; import java.io.File; @@ -30,9 +31,9 @@ import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.FileStore; import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Comparator; import java.util.Date; import java.util.logging.ConsoleHandler; import java.util.logging.Formatter; @@ -40,6 +41,7 @@ import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; +import java.util.stream.Stream; public final class Log { @@ -278,17 +280,22 @@ public final class Log { } public static long[] getStorageSpace() { - long usable = 0; - long total = 0; - for (Path root : FileSystems.getDefault().getRootDirectories()) { + var stores = new ArrayList<Pair<Long, Long>>(); + for (FileStore store : FileSystems.getDefault().getFileStores()) { try { - FileStore store = Files.getFileStore(root); - usable += store.getUsableSpace(); - total += store.getTotalSpace(); + long usableSpace = store.getUsableSpace(); + long totalSpace = store.getTotalSpace(); + if (totalSpace > 1_000_000_000) { + stores.add(new Pair<>(usableSpace, totalSpace)); + } } catch (IOException ignored) { } } - return new long[]{usable, total}; + return stores.stream() + .sorted(Comparator.comparingDouble(p -> p.getFirst() / (double) p.getSecond())) + .flatMap(p -> Stream.of(p.getFirst(), p.getSecond())) + .mapToLong(Long::longValue) + .toArray(); } } diff --git a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java index 6be3d2dc3..c8ea66b6c 100644 --- a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java @@ -112,6 +112,9 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { case "TOWED": position.set(Position.KEY_ALARM, Position.ALARM_TOW); break; + case "SHAKE": + position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION); + break; case "SOS": position.set(Position.KEY_ALARM, Position.ALARM_SOS); break; |