mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2026-03-22 10:15:50 +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 * as fs from "@tauri-apps/plugin-fs";
|
||||||
import { useKvPairs } from "@/helpers/use-kvpairs";
|
import { useKvPairs } from "@/helpers/use-kvpairs";
|
||||||
import { useSettingsPageStatesStore } from "@/services/store";
|
import { useSettingsPageStatesStore } from "@/services/store";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { useLogger } from "@/helpers/use-logger";
|
|
||||||
|
|
||||||
interface FileMap {
|
interface FileMap {
|
||||||
source: string;
|
source: string;
|
||||||
@@ -13,7 +12,6 @@ interface FileMap {
|
|||||||
|
|
||||||
export function useLinuxRegisterer() {
|
export function useLinuxRegisterer() {
|
||||||
const { saveKvPair } = useKvPairs();
|
const { saveKvPair } = useKvPairs();
|
||||||
const LOG = useLogger();
|
|
||||||
const appVersion = useSettingsPageStatesStore(state => state.appVersion);
|
const appVersion = useSettingsPageStatesStore(state => state.appVersion);
|
||||||
|
|
||||||
const registerToLinux = async () => {
|
const registerToLinux = async () => {
|
||||||
@@ -25,16 +23,18 @@ export function useLinuxRegisterer() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const isFlatpak = await invoke<boolean>('is_flatpak');
|
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||||
const resourceDirPath = isFlatpak ? '/app/lib/neodlp' : await resourceDir();
|
const resourceDirPath = await resourceDir();
|
||||||
const homeDirPath = await homeDir();
|
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) {
|
for (const file of filesToCopy) {
|
||||||
const sourcePath = await join(resourceDirPath, file.source);
|
const sourcePath = await join(resourceDirPath, file.source);
|
||||||
const destinationDir = isFlatpak ? await join(configDirPath, file.dir) : await join(homeDirPath, file.dir);
|
const destinationDir = await join(homeDirPath, file.dir);
|
||||||
const destinationPath = isFlatpak ? await join(configDirPath, file.destination) : await join(homeDirPath, file.destination);
|
const destinationPath = await join(homeDirPath, file.destination);
|
||||||
|
|
||||||
const dirExists = await fs.exists(destinationDir);
|
const dirExists = await fs.exists(destinationDir);
|
||||||
if (dirExists) {
|
if (dirExists) {
|
||||||
@@ -51,7 +51,6 @@ export function useLinuxRegisterer() {
|
|||||||
return { success: true, message: 'Registered successfully' }
|
return { success: true, message: 'Registered successfully' }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error copying files:', error);
|
console.error('Error copying files:', error);
|
||||||
LOG.error("LINUX REGISTERER", `Error during registration: ${error}`);
|
|
||||||
return { success: false, message: 'Failed to register' }
|
return { success: false, message: 'Failed to register' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,11 @@ export function useYtDlpUpdater() {
|
|||||||
|
|
||||||
const updateYtDlp = async () => {
|
const updateYtDlp = async () => {
|
||||||
const CURRENT_TIMESTAMP = Date.now();
|
const CURRENT_TIMESTAMP = Date.now();
|
||||||
|
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||||
setIsUpdatingYtDlp(true);
|
setIsUpdatingYtDlp(true);
|
||||||
LOG.info('NEODLP', 'Updating yt-dlp to latest version');
|
LOG.info('NEODLP', 'Updating yt-dlp to latest version');
|
||||||
try {
|
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();
|
const output = await command.execute();
|
||||||
if (output.code === 0) {
|
if (output.code === 0) {
|
||||||
console.log("yt-dlp updated successfully:", output.stdout);
|
console.log("yt-dlp updated successfully:", output.stdout);
|
||||||
|
|||||||
Reference in New Issue
Block a user