From ed4ccf4ba3dad1af05d323f2f60ebc9867f07649 Mon Sep 17 00:00:00 2001 From: Rainxch Zed Date: Fri, 28 Nov 2025 10:29:19 +0500 Subject: [PATCH 1/2] Added logs to debug --- .../feature/details/data/DesktopInstaller.kt | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/feature/details/data/DesktopInstaller.kt b/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/feature/details/data/DesktopInstaller.kt index 6207769e6..41ebb0116 100644 --- a/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/feature/details/data/DesktopInstaller.kt +++ b/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/feature/details/data/DesktopInstaller.kt @@ -1,5 +1,6 @@ package zed.rainxch.githubstore.feature.details.data +import co.touchlab.kermit.Logger import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import zed.rainxch.githubstore.feature.home.data.repository.PlatformType @@ -140,45 +141,77 @@ class DesktopInstaller( } private fun installAppImage(file: File) { + Logger.d { "Installing AppImage: ${file.absolutePath}" } + // Get Desktop directory val desktopDir = getDesktopDirectory() + Logger.d { "Desktop directory: ${desktopDir.absolutePath}" } + Logger.d { "Desktop exists: ${desktopDir.exists()}, isDirectory: ${desktopDir.isDirectory}, canWrite: ${desktopDir.canWrite()}" } // Copy file to desktop with its original name val destinationFile = File(desktopDir, file.name) // If file already exists on desktop, add a number suffix val finalDestination = if (destinationFile.exists()) { + Logger.d { "File already exists, generating unique name" } generateUniqueFileName(desktopDir, file.name) } else { destinationFile } + Logger.d { "Final destination: ${finalDestination.absolutePath}" } + try { // Copy the file + Logger.d { "Copying file..." } file.copyTo(finalDestination, overwrite = false) + Logger.d { "Copy successful, file size: ${finalDestination.length()} bytes" } // Make it executable - finalDestination.setExecutable(true, false) + val executableSet = finalDestination.setExecutable(true, false) + Logger.d { "Set executable: $executableSet" } + + // Verify the file exists + if (!finalDestination.exists()) { + throw IllegalStateException("File was copied but doesn't exist at destination") + } // Optionally, try to open the desktop folder to show the file try { + Logger.d { "Attempting to open desktop folder..." } if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(desktopDir) + Logger.d { "Desktop folder opened" } + } else { + Logger.w { "Desktop not supported, trying xdg-open" } + ProcessBuilder("xdg-open", desktopDir.absolutePath).start() } } catch (e: Exception) { - // Ignore if we can't open the folder + Logger.w { "Could not open desktop folder: ${e.message}" } + // Not a critical error, just log it } + + Logger.d { "AppImage installation completed successfully" } } catch (e: IOException) { + Logger.e { "Failed to copy AppImage: ${e.message}" } + e.printStackTrace() throw IllegalStateException( "Failed to copy AppImage to desktop: ${e.message}. " + + "Desktop path: ${desktopDir.absolutePath}. " + "Please ensure you have write permissions to your Desktop folder.", e ) } catch (e: SecurityException) { + Logger.e { "Security exception: ${e.message}" } + e.printStackTrace() throw IllegalStateException( "Security restrictions prevent copying AppImage to desktop.", e ) + } catch (e: Exception) { + Logger.e { "Unexpected error: ${e.message}" } + e.printStackTrace() + throw IllegalStateException("Failed to install AppImage: ${e.message}", e) } } From 724e20d3ccb4a45814b7177bb1e6e2784fa511a3 Mon Sep 17 00:00:00 2001 From: Rainxch Zed Date: Fri, 28 Nov 2025 10:35:45 +0500 Subject: [PATCH 2/2] Remove "files" property because that's unnecessary --- .../kotlin/zed/rainxch/githubstore/app/di/PlatformModules.jvm.kt | 1 - .../rainxch/githubstore/feature/details/data/DesktopInstaller.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/app/di/PlatformModules.jvm.kt b/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/app/di/PlatformModules.jvm.kt index aac8c3fa8..9c750981b 100644 --- a/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/app/di/PlatformModules.jvm.kt +++ b/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/app/di/PlatformModules.jvm.kt @@ -23,7 +23,6 @@ actual val platformModule: Module = module { single { val platform = getPlatform() DesktopInstaller( - files = get(), platform = platform.type ) } diff --git a/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/feature/details/data/DesktopInstaller.kt b/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/feature/details/data/DesktopInstaller.kt index 41ebb0116..fb22e9e49 100644 --- a/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/feature/details/data/DesktopInstaller.kt +++ b/composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/feature/details/data/DesktopInstaller.kt @@ -9,7 +9,6 @@ import java.io.File import java.io.IOException class DesktopInstaller( - private val files: FileLocationsProvider, private val platform: PlatformType ) : Installer {