diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/App.kt b/src/main/kotlin/com/jetpackduba/gitnuro/App.kt index 6d03c95..f12fdba 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/App.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/App.kt @@ -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() } diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/di/AppComponent.kt b/src/main/kotlin/com/jetpackduba/gitnuro/di/AppComponent.kt index e93eac0..b050678 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/di/AppComponent.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/di/AppComponent.kt @@ -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 } \ No newline at end of file diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/managers/TempFilesManager.kt b/src/main/kotlin/com/jetpackduba/gitnuro/managers/TempFilesManager.kt index 8ce2087..87f84d2 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/managers/TempFilesManager.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/managers/TempFilesManager.kt @@ -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") + return appDataDir.openDirectory("tmp") + } - if (!tempDir.exists() || !tempDir.isDirectory) { - tempDir.mkdir() - } - - return tempDir + fun clearAll() { + val dir = tempDir() + dir.deleteRecursively() } } \ No newline at end of file