Updated math to use Math.round to help get better values. Updated code

for determining if Vera is available so as to not show those screens.
Updated file handling as there were issues due to no checks for file
handling, this will improve for windows.
This commit is contained in:
Admin
2015-10-13 16:30:45 -05:00
parent c5fbd5d1f0
commit 7c1d6e40b8
7 changed files with 33 additions and 20 deletions

View File

@@ -107,10 +107,14 @@ public class DeviceRepository {
}
try {
Path target = FileSystems.getDefault().getPath("data", "device.db.old");
Files.move(filePath, target);
Path target = null;
if(Files.exists(filePath)) {
target = FileSystems.getDefault().getPath(filePath.getParent().toString(), "device.db.old");
Files.move(filePath, target);
}
Files.write(filePath, content.getBytes(), StandardOpenOption.CREATE);
Files.delete(target);
if(target != null)
Files.delete(target);
} catch (IOException e) {
log.error("Error writing the file: " + filePath + " message: " + e.getMessage(), e);
}
@@ -120,7 +124,7 @@ public class DeviceRepository {
String content = null;
if(Files.notExists(filePath) || !Files.isReadable(filePath)){
log.error("Error reading the file: " + filePath + " - Does not exist or is not readable. ");
log.warn("Error reading the file: " + filePath + " - Does not exist or is not readable. continuing...");
return null;
}