mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2026-03-22 11:25:49 +05:30
refactor: disable linux registration and fix yt-dlp updater on flatpak
This commit is contained in:
@@ -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<boolean>('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' }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,11 @@ export function useYtDlpUpdater() {
|
||||
|
||||
const updateYtDlp = async () => {
|
||||
const CURRENT_TIMESTAMP = Date.now();
|
||||
const isFlatpak = await invoke<boolean>('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);
|
||||
|
||||
Reference in New Issue
Block a user