From 32d63be13ec42cace55f9f6488d89a8060ce50ce Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Tue, 24 Feb 2026 10:00:51 +0530 Subject: [PATCH] refactor: disable linux registration and fix yt-dlp updater on flatpak --- src/helpers/use-linux-registerer.ts | 17 ++++++++--------- src/helpers/use-ytdlp-updater.ts | 3 ++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/helpers/use-linux-registerer.ts b/src/helpers/use-linux-registerer.ts index 107f0e8..27c8067 100644 --- a/src/helpers/use-linux-registerer.ts +++ b/src/helpers/use-linux-registerer.ts @@ -1,9 +1,8 @@ -import { join, resourceDir, homeDir, configDir } from "@tauri-apps/api/path"; +import { join, resourceDir, homeDir } from "@tauri-apps/api/path"; import * as fs from "@tauri-apps/plugin-fs"; import { useKvPairs } from "@/helpers/use-kvpairs"; import { useSettingsPageStatesStore } from "@/services/store"; import { invoke } from "@tauri-apps/api/core"; -import { useLogger } from "@/helpers/use-logger"; interface FileMap { source: string; @@ -13,7 +12,6 @@ interface FileMap { export function useLinuxRegisterer() { const { saveKvPair } = useKvPairs(); - const LOG = useLogger(); const appVersion = useSettingsPageStatesStore(state => state.appVersion); const registerToLinux = async () => { @@ -25,16 +23,18 @@ export function useLinuxRegisterer() { ]; const isFlatpak = await invoke('is_flatpak'); - const resourceDirPath = isFlatpak ? '/app/lib/neodlp' : await resourceDir(); + const resourceDirPath = await resourceDir(); const homeDirPath = await homeDir(); - const configDirPath = await configDir(); - LOG.info("LINUX REGISTERER", `Starting registration process. isFlatpak: ${isFlatpak}, resourceDirPath: ${resourceDirPath}, homeDirPath: ${homeDirPath}, configDirPath: ${configDirPath}`); + if (isFlatpak) { + saveKvPair('linux_registered_version', appVersion); + return { success: true, message: 'Registered successfully' } + } for (const file of filesToCopy) { const sourcePath = await join(resourceDirPath, file.source); - const destinationDir = isFlatpak ? await join(configDirPath, file.dir) : await join(homeDirPath, file.dir); - const destinationPath = isFlatpak ? await join(configDirPath, file.destination) : await join(homeDirPath, file.destination); + const destinationDir = await join(homeDirPath, file.dir); + const destinationPath = await join(homeDirPath, file.destination); const dirExists = await fs.exists(destinationDir); if (dirExists) { @@ -51,7 +51,6 @@ export function useLinuxRegisterer() { return { success: true, message: 'Registered successfully' } } catch (error) { console.error('Error copying files:', error); - LOG.error("LINUX REGISTERER", `Error during registration: ${error}`); return { success: false, message: 'Failed to register' } } } diff --git a/src/helpers/use-ytdlp-updater.ts b/src/helpers/use-ytdlp-updater.ts index a50c346..fc6cec1 100644 --- a/src/helpers/use-ytdlp-updater.ts +++ b/src/helpers/use-ytdlp-updater.ts @@ -17,10 +17,11 @@ export function useYtDlpUpdater() { const updateYtDlp = async () => { const CURRENT_TIMESTAMP = Date.now(); + const isFlatpak = await invoke('is_flatpak'); setIsUpdatingYtDlp(true); LOG.info('NEODLP', 'Updating yt-dlp to latest version'); try { - const command = currentPlatform === 'linux' ? Command.create('pkexec', ['yt-dlp', '--update-to', ytDlpUpdateChannel]) : Command.sidecar('binaries/yt-dlp', ['--update-to', ytDlpUpdateChannel]); + const command = currentPlatform === 'linux' && !isFlatpak ? Command.create('pkexec', ['yt-dlp', '--update-to', ytDlpUpdateChannel]) : Command.sidecar('binaries/yt-dlp', ['--update-to', ytDlpUpdateChannel]); const output = await command.execute(); if (output.code === 0) { console.log("yt-dlp updated successfully:", output.stdout);