Skip to content

Commit

Permalink
убрал дублированное хранение
Browse files Browse the repository at this point in the history
  • Loading branch information
theshadowco committed Mar 12, 2024
1 parent 54f6dc2 commit 206b748
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static Map<String, SupportVariant> readSimple(Path path) {
var rootPath = getRootPathByParentConfigurations(path);
var supportMap = SUPPORT_SIMPLE_MAPS.get(rootPath);
if (supportMap == null && path.toFile().exists()) {
readFile(path, rootPath);
readFile(path, rootPath, false);
supportMap = SUPPORT_SIMPLE_MAPS.get(rootPath);
}

Expand All @@ -97,7 +97,7 @@ public static Map<String, Map<SupportConfiguration, SupportVariant>> readFull(Pa
var rootPath = getRootPathByParentConfigurations(path);
var supportMap = SUPPORT_MAPS.get(rootPath);
if (supportMap == null && path.toFile().exists()) {
readFile(path, rootPath);
readFile(path, rootPath, true);
supportMap = SUPPORT_MAPS.get(rootPath);
}

Expand Down Expand Up @@ -125,17 +125,19 @@ public static SupportVariant getSupportVariantByMDO(String uuid, Path path) {
return SupportVariant.NONE;
}

private void readFile(Path pathToBinFile, Path rootPath) {
LOGGER.debug("Чтения файла поставки ParentConfigurations.bin");
private void readFile(Path pathToBinFile, Path rootPath, boolean fullRead) {
LOGGER.debug("Чтения файла поставки ParentConfigurations.bin, полное чтение = " + fullRead);

try {
var supportMap = read(pathToBinFile);
SUPPORT_MAPS.put(rootPath, supportMap);

Map<String, SupportVariant> result = new HashMap<>();
supportMap.forEach((String uuid, Map<SupportConfiguration, SupportVariant> supportVariantMap)
-> result.put(uuid, SupportVariant.max(supportVariantMap.values())));
SUPPORT_SIMPLE_MAPS.put(rootPath, result);
if(fullRead) {
SUPPORT_MAPS.put(rootPath, supportMap);
} else {
Map<String, SupportVariant> result = new HashMap<>();
supportMap.forEach((String uuid, Map<SupportConfiguration, SupportVariant> supportVariantMap)
-> result.put(uuid, SupportVariant.max(supportVariantMap.values())));
SUPPORT_SIMPLE_MAPS.put(rootPath, result);
}
} catch (FileNotFoundException | NumberFormatException exception) {
LOGGER.error(
String.format("Ошибка чтения файла %s", pathToBinFile.toFile()));
Expand Down

0 comments on commit 206b748

Please sign in to comment.