Delete native library if it already exists (#179)

* Delete native library if it already exists

* Spotless
This commit is contained in:
Matt
2020-12-13 16:32:00 -08:00
committed by GitHub
parent 11a66b15ed
commit c7d092a775
2 changed files with 4 additions and 1 deletions

View File

@@ -45,7 +45,10 @@ public class PicamJNI {
URL resourceURL = PicamJNI.class.getResource("/nativelibraries/libpicam.so");
File libFile = Path.of("lib/libpicam.so").toFile();
try (InputStream in = resourceURL.openStream()) {
if (libFile.exists()) Files.delete(libFile.toPath());
Files.copy(in, libFile.toPath());
} catch (Exception e) {
logger.error("Could not extract the native library!");
}
System.load(libFile.getAbsolutePath());

View File

@@ -188,7 +188,7 @@ public class RequestHandler {
if (Platform.isRaspberryPi()) {
try {
new ShellExec().executeBashCommand("systemctl restart photonvision");
new ShellExec().executeBashCommand("systemctl restart photonvision.service");
} catch (IOException e) {
logger.error("Could not restart device!", e);
System.exit(0);