Added temporary directory removal when closing the app
This commit is contained in:
parent
4b523e0aed
commit
8b74329fb0
3 changed files with 15 additions and 7 deletions
|
@ -24,6 +24,7 @@ import com.jetpackduba.gitnuro.extensions.toWindowPlacement
|
|||
import com.jetpackduba.gitnuro.git.AppGpgSigner
|
||||
import com.jetpackduba.gitnuro.logging.printError
|
||||
import com.jetpackduba.gitnuro.managers.AppStateManager
|
||||
import com.jetpackduba.gitnuro.managers.TempFilesManager
|
||||
import com.jetpackduba.gitnuro.preferences.AppSettings
|
||||
import com.jetpackduba.gitnuro.system.systemSeparator
|
||||
import com.jetpackduba.gitnuro.theme.AppTheme
|
||||
|
@ -62,6 +63,9 @@ class App {
|
|||
@Inject
|
||||
lateinit var tabsManager: TabsManager
|
||||
|
||||
@Inject
|
||||
lateinit var tempFilesManager: TempFilesManager
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
}
|
||||
|
@ -134,6 +138,7 @@ class App {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
tempFilesManager.clearAll()
|
||||
appStateManager.cancelCoroutines()
|
||||
this.exitApplication()
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.jetpackduba.gitnuro.di.modules.AppModule
|
|||
import com.jetpackduba.gitnuro.di.modules.ShellModule
|
||||
import com.jetpackduba.gitnuro.managers.AppStateManager
|
||||
import com.jetpackduba.gitnuro.managers.IShellManager
|
||||
import com.jetpackduba.gitnuro.managers.TempFilesManager
|
||||
import com.jetpackduba.gitnuro.preferences.AppSettings
|
||||
import com.jetpackduba.gitnuro.terminal.ITerminalProvider
|
||||
import com.jetpackduba.gitnuro.ui.TabsManager
|
||||
|
@ -36,4 +37,6 @@ interface AppComponent {
|
|||
fun shellManager(): IShellManager
|
||||
|
||||
fun terminalProvider(): ITerminalProvider
|
||||
|
||||
fun tempFilesManager(): TempFilesManager
|
||||
}
|
|
@ -4,19 +4,19 @@ import com.jetpackduba.gitnuro.di.TabScope
|
|||
import com.jetpackduba.gitnuro.extensions.openDirectory
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@TabScope
|
||||
@Singleton
|
||||
class TempFilesManager @Inject constructor(
|
||||
private val appFilesManager: AppFilesManager,
|
||||
) {
|
||||
fun tempDir(): File {
|
||||
val appDataDir = appFilesManager.getAppFolder()
|
||||
val tempDir = appDataDir.openDirectory("tmp")
|
||||
|
||||
if (!tempDir.exists() || !tempDir.isDirectory) {
|
||||
tempDir.mkdir()
|
||||
return appDataDir.openDirectory("tmp")
|
||||
}
|
||||
|
||||
return tempDir
|
||||
fun clearAll() {
|
||||
val dir = tempDir()
|
||||
dir.deleteRecursively()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue