mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-25 10:32:00 +01:00
updated console output per issue #1000
This commit is contained in:
@@ -68,7 +68,7 @@ public class H2DBLock {
|
|||||||
* A random string used to validate the lock.
|
* A random string used to validate the lock.
|
||||||
*/
|
*/
|
||||||
private final String magic;
|
private final String magic;
|
||||||
|
|
||||||
private H2DBCleanupHook hook = null;
|
private H2DBCleanupHook hook = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,16 +102,7 @@ public class H2DBLock {
|
|||||||
try {
|
try {
|
||||||
final File dir = settings.getDataDirectory();
|
final File dir = settings.getDataDirectory();
|
||||||
lockFile = new File(dir, "dc.update.lock");
|
lockFile = new File(dir, "dc.update.lock");
|
||||||
if (!lockFile.getParentFile().isDirectory() && !lockFile.mkdir()) {
|
checkState();
|
||||||
throw new H2DBLockException("Unable to create path to data directory.");
|
|
||||||
}
|
|
||||||
if (lockFile.isFile() && getFileAge(lockFile) > 30) {
|
|
||||||
LOGGER.debug("An old db update lock file was found: {}", lockFile.getAbsolutePath());
|
|
||||||
if (!lockFile.delete()) {
|
|
||||||
LOGGER.warn("An old db update lock file was found but the system was unable to delete "
|
|
||||||
+ "the file. Consider manually deleting {}", lockFile.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int ctr = 0;
|
int ctr = 0;
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
@@ -165,6 +156,24 @@ public class H2DBLock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkState() throws H2DBLockException {
|
||||||
|
if (!lockFile.getParentFile().isDirectory() && !lockFile.mkdir()) {
|
||||||
|
throw new H2DBLockException("Unable to create path to data directory.");
|
||||||
|
}
|
||||||
|
if (lockFile.isFile()) {
|
||||||
|
if (getFileAge(lockFile) > 30) {
|
||||||
|
LOGGER.debug("An old db update lock file was found: {}", lockFile.getAbsolutePath());
|
||||||
|
if (!lockFile.delete()) {
|
||||||
|
LOGGER.warn("An old db update lock file was found but the system was unable to delete "
|
||||||
|
+ "the file. Consider manually deleting {}", lockFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOGGER.info("Lock file found `{}`", lockFile);
|
||||||
|
LOGGER.info("Existing update in progress; waiting for update to complete");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Releases the lock on the H2 database.
|
* Releases the lock on the H2 database.
|
||||||
*/
|
*/
|
||||||
@@ -217,14 +226,14 @@ public class H2DBLock {
|
|||||||
LOGGER.debug("Lock file age is {} minutes", time);
|
LOGGER.debug("Lock file age is {} minutes", time);
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addShutdownHook() {
|
private void addShutdownHook() {
|
||||||
if (hook == null) {
|
if (hook == null) {
|
||||||
hook = new H2DBCleanupHook(this);
|
hook = new H2DBCleanupHook(this);
|
||||||
Runtime.getRuntime().addShutdownHook(hook);
|
Runtime.getRuntime().addShutdownHook(hook);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeShutdownHook() {
|
private void removeShutdownHook() {
|
||||||
if (hook != null) {
|
if (hook != null) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user