Skip to content

Commit 32d63be

Browse files
committed
refactor: disable linux registration and fix yt-dlp updater on flatpak
1 parent 1ba035e commit 32d63be

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/helpers/use-linux-registerer.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { join, resourceDir, homeDir, configDir } from "@tauri-apps/api/path";
1+
import { join, resourceDir, homeDir } from "@tauri-apps/api/path";
22
import * as fs from "@tauri-apps/plugin-fs";
33
import { useKvPairs } from "@/helpers/use-kvpairs";
44
import { useSettingsPageStatesStore } from "@/services/store";
55
import { invoke } from "@tauri-apps/api/core";
6-
import { useLogger } from "@/helpers/use-logger";
76

87
interface FileMap {
98
source: string;
@@ -13,7 +12,6 @@ interface FileMap {
1312

1413
export function useLinuxRegisterer() {
1514
const { saveKvPair } = useKvPairs();
16-
const LOG = useLogger();
1715
const appVersion = useSettingsPageStatesStore(state => state.appVersion);
1816

1917
const registerToLinux = async () => {
@@ -25,16 +23,18 @@ export function useLinuxRegisterer() {
2523
];
2624

2725
const isFlatpak = await invoke<boolean>('is_flatpak');
28-
const resourceDirPath = isFlatpak ? '/app/lib/neodlp' : await resourceDir();
26+
const resourceDirPath = await resourceDir();
2927
const homeDirPath = await homeDir();
30-
const configDirPath = await configDir();
3128

32-
LOG.info("LINUX REGISTERER", `Starting registration process. isFlatpak: ${isFlatpak}, resourceDirPath: ${resourceDirPath}, homeDirPath: ${homeDirPath}, configDirPath: ${configDirPath}`);
29+
if (isFlatpak) {
30+
saveKvPair('linux_registered_version', appVersion);
31+
return { success: true, message: 'Registered successfully' }
32+
}
3333

3434
for (const file of filesToCopy) {
3535
const sourcePath = await join(resourceDirPath, file.source);
36-
const destinationDir = isFlatpak ? await join(configDirPath, file.dir) : await join(homeDirPath, file.dir);
37-
const destinationPath = isFlatpak ? await join(configDirPath, file.destination) : await join(homeDirPath, file.destination);
36+
const destinationDir = await join(homeDirPath, file.dir);
37+
const destinationPath = await join(homeDirPath, file.destination);
3838

3939
const dirExists = await fs.exists(destinationDir);
4040
if (dirExists) {
@@ -51,7 +51,6 @@ export function useLinuxRegisterer() {
5151
return { success: true, message: 'Registered successfully' }
5252
} catch (error) {
5353
console.error('Error copying files:', error);
54-
LOG.error("LINUX REGISTERER", `Error during registration: ${error}`);
5554
return { success: false, message: 'Failed to register' }
5655
}
5756
}

src/helpers/use-ytdlp-updater.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ export function useYtDlpUpdater() {
1717

1818
const updateYtDlp = async () => {
1919
const CURRENT_TIMESTAMP = Date.now();
20+
const isFlatpak = await invoke<boolean>('is_flatpak');
2021
setIsUpdatingYtDlp(true);
2122
LOG.info('NEODLP', 'Updating yt-dlp to latest version');
2223
try {
23-
const command = currentPlatform === 'linux' ? Command.create('pkexec', ['yt-dlp', '--update-to', ytDlpUpdateChannel]) : Command.sidecar('binaries/yt-dlp', ['--update-to', ytDlpUpdateChannel]);
24+
const command = currentPlatform === 'linux' && !isFlatpak ? Command.create('pkexec', ['yt-dlp', '--update-to', ytDlpUpdateChannel]) : Command.sidecar('binaries/yt-dlp', ['--update-to', ytDlpUpdateChannel]);
2425
const output = await command.execute();
2526
if (output.code === 0) {
2627
console.log("yt-dlp updated successfully:", output.stdout);

0 commit comments

Comments
 (0)