Skip to content
Snippets Groups Projects
Verified Commit 842275fc authored by Torsten Grote's avatar Torsten Grote
Browse files

Do not start lifecycle when wiping from CLI

parent 6f5a62ad
No related branches found
No related tags found
1 merge request!52Use existence of DB folder to signal if the mailbox is set up or not
Pipeline #9501 passed
...@@ -107,6 +107,15 @@ class Main : CliktCommand( ...@@ -107,6 +107,15 @@ class Main : CliktCommand(
val javaCliComponent = DaggerJavaCliComponent.builder().build() val javaCliComponent = DaggerJavaCliComponent.builder().build()
javaCliComponent.inject(this) javaCliComponent.inject(this)
if (wipe) {
wipeManager.wipeFilesOnly()
println("Mailbox wiped successfully \\o/")
exitProcess(0)
}
startLifecycle()
}
private fun startLifecycle() {
Runtime.getRuntime().addShutdownHook( Runtime.getRuntime().addShutdownHook(
Thread { Thread {
lifecycleManager.stopServices() lifecycleManager.stopServices()
...@@ -114,24 +123,10 @@ class Main : CliktCommand( ...@@ -114,24 +123,10 @@ class Main : CliktCommand(
} }
) )
// This is a cli app, we'll always want this fully up when started, so start lifecycle
lifecycleManager.startServices() lifecycleManager.startServices()
lifecycleManager.waitForStartup() lifecycleManager.waitForStartup()
if (wipe) { if (setupToken != null) {
// FIXME this can cause a deadlock
// see: https://code.briarproject.org/briar/briar-mailbox/-/issues/76
val wipeResult = lifecycleManager.wipeMailbox()
lifecycleManager.stopServices()
lifecycleManager.waitForShutdown()
if (wipeResult) {
println("Mailbox wiped successfully \\o/")
exitProcess(0)
} else {
println("ERROR: Mailbox was not wiped cleanly")
exitProcess(1)
}
} else if (setupToken != null) {
try { try {
setupManager.setToken(setupToken, null) setupManager.setToken(setupToken, null)
} catch (e: InvalidIdException) { } catch (e: InvalidIdException) {
......
...@@ -49,7 +49,8 @@ class WipeManager @Inject constructor( ...@@ -49,7 +49,8 @@ class WipeManager @Inject constructor(
/** /**
* Deletes all files, includes the database files. * Deletes all files, includes the database files.
* *
* This must only be called by the [LifecycleManager]. * This must only be called by the [LifecycleManager]
* or by the CLI when no lifecycle was started.
*/ */
fun wipeFilesOnly() { fun wipeFilesOnly() {
fileManager.deleteAllFiles() fileManager.deleteAllFiles()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment