better error handling in case of local .ini
This commit is contained in:
parent
e34d38bcc2
commit
6801eb0a0d
|
@ -25,7 +25,11 @@ public class IniFileMetaInfoImpl implements IniFileMetaInfo {
|
|||
public IniFileMetaInfoImpl(RawIniFile file) {
|
||||
|
||||
nPages = file.getSimpleIntegerProperty("nPages", 1);
|
||||
ochBlockSize = file.getSimpleIntegerProperty("ochBlockSize");
|
||||
try {
|
||||
ochBlockSize = file.getSimpleIntegerProperty("ochBlockSize");
|
||||
} catch (Throwable e) {
|
||||
throw new IllegalStateException("Error while reading " + file.msg);
|
||||
}
|
||||
|
||||
blockingFactor = file.getSimpleIntegerProperty("blockingFactor", DEFAULT_BLOCKING_FACTOR);
|
||||
|
||||
|
|
|
@ -79,10 +79,13 @@ public class IniFileReader {
|
|||
return c == ' ' || c == '\t' || c == '=' || c == ',';
|
||||
}
|
||||
|
||||
public static RawIniFile read(InputStream in) {
|
||||
return read(in, "unknown");
|
||||
}
|
||||
/**
|
||||
* Just grabs an collection of lines, no parsing logic here
|
||||
*/
|
||||
public static RawIniFile read(InputStream in) {
|
||||
public static RawIniFile read(InputStream in, String msg) {
|
||||
List<RawIniFile.Line> lines = new ArrayList<>();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
|
||||
|
@ -97,13 +100,13 @@ public class IniFileReader {
|
|||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
return new RawIniFile(lines);
|
||||
return new RawIniFile(lines, msg);
|
||||
}
|
||||
|
||||
public static RawIniFile read(File input) {
|
||||
try {
|
||||
InputStream in = new FileInputStream(input);
|
||||
return read(in);
|
||||
return read(in, input.getAbsolutePath());
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public class RawIniFile {
|
|||
* A list of lines. Lines which are only a comment were filtered out already.
|
||||
*/
|
||||
private final List<Line> lines;
|
||||
final String msg;
|
||||
|
||||
/**
|
||||
* Often we want to look-up line by first token.
|
||||
|
@ -25,8 +26,9 @@ public class RawIniFile {
|
|||
*/
|
||||
private final Map<String, Line> asSet = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
public RawIniFile(List<Line> lines) {
|
||||
public RawIniFile(List<Line> lines, String msg) {
|
||||
this.lines = lines;
|
||||
this.msg = msg;
|
||||
|
||||
for (Line line : lines) {
|
||||
if (line.tokens.length > 1)
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package com.rusefi.binaryprotocol;
|
||||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.core.SignatureHelper;
|
||||
|
||||
import static com.devexperts.logging.Logging.getLogging;
|
||||
|
||||
public class RealIniFileProvider implements IniFileProvider {
|
||||
private static final Logging log = getLogging(RealIniFileProvider.class);
|
||||
@Override
|
||||
public IniFileModel provide(String signature) {
|
||||
/**
|
||||
|
@ -14,6 +18,7 @@ public class RealIniFileProvider implements IniFileProvider {
|
|||
*/
|
||||
String localIniFile = SignatureHelper.downloadIfNotAvailable(SignatureHelper.getUrl(signature));
|
||||
if (localIniFile == null) {
|
||||
log.info("Failed to download " + signature + " maybe custom board?");
|
||||
// 4th option: current folder
|
||||
localIniFile = IniFileModelImpl.findIniFile(".");
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ public class FindFileHelper {
|
|||
@Nullable
|
||||
public static String findFile(String fileDirectory, String prefix, String suffix) {
|
||||
File dir = new File(fileDirectory);
|
||||
log.info("Scanning " + dir.getAbsolutePath() + " for " + prefix + "/" + suffix);
|
||||
if (!dir.isDirectory()) {
|
||||
throw new IllegalStateException("Not a directory: " + fileDirectory);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public interface rusEFIVersion {
|
|||
* *** BE CAREFUL WE HAVE SEPARATE AUTOUPDATE_VERSION also managed manually ***
|
||||
* @see com.rusefi.autoupdate.Autoupdate#AUTOUPDATE_VERSION
|
||||
*/
|
||||
int CONSOLE_VERSION = 20241031;
|
||||
int CONSOLE_VERSION = 20241120;
|
||||
AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
static long classBuildTimeMillis() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="11" project-jdk-type="JavaSDK" />
|
||||
</project>
|
|
@ -17,8 +17,6 @@
|
|||
<mapping directory="$PROJECT_DIR$/../firmware/controllers/can/wideband_firmware/firmware/ext/openblt" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../firmware/controllers/can/wideband_firmware/firmware/libfirmware" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../firmware/controllers/can/wideband_firmware/kicad-libraries" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../firmware/controllers/can/wideband_firmware/kicad-libraries/Fabrication/InteractiveHtmlBom" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../firmware/controllers/can/wideband_firmware/kicad-libraries/Fabrication/bom_jlc" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../firmware/controllers/can/wideband_firmware/test/googletest" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../firmware/controllers/lua/luaaa" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../firmware/ext/lua" vcs="Git" />
|
||||
|
@ -35,4 +33,4 @@
|
|||
<mapping directory="$PROJECT_DIR$/../misc/hex2dfu" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../unit_tests/googletest" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
</project>
|
Loading…
Reference in New Issue