1
1
mirror of https://github.com/neosubhamoy/neodlp.git synced 2026-03-22 03:25:49 +05:30

refactor: disable potoken on flatpak

This commit is contained in:
2026-03-07 09:50:14 +05:30
Verified
parent 7780c611b5
commit 2211f252c7
4 changed files with 45 additions and 38 deletions

View File

@@ -39,7 +39,7 @@
</screenshots>
<content_rating type="oars-1.1" />
<releases>
<release version="0.4.3" date="2026-03-06">
<release version="0.4.3" date="2026-03-07">
<url type="details">https://github.com/neosubhamoy/neodlp/releases/tag/v0.4.3</url>
</release>
</releases>

View File

@@ -1254,6 +1254,8 @@ function AppDelaySettings() {
}
function AppPoTokenSettings() {
const isFlatpak = useEnvironmentStore(state => state.isFlatpak);
const formResetTrigger = useSettingsPageStatesStore(state => state.formResetTrigger);
const acknowledgeFormReset = useSettingsPageStatesStore(state => state.acknowledgeFormReset);
@@ -1325,7 +1327,7 @@ function AppPoTokenSettings() {
await stopPotServer();
}
}}
disabled={useCustomCommands || isStartingPotServer || isChangingPotServerPort}
disabled={useCustomCommands || isStartingPotServer || isChangingPotServerPort || isFlatpak}
/>
<Label htmlFor="use-potoken">Use PO Token</Label>
</div>
@@ -1351,7 +1353,7 @@ function AppPoTokenSettings() {
id="disable-innertube"
checked={disableInnertube}
onCheckedChange={(checked) => saveSettingsKey('disable_innertube', checked)}
disabled={useCustomCommands || !usePotoken}
disabled={useCustomCommands || !usePotoken || isFlatpak}
/>
</div>
</div>
@@ -1364,7 +1366,7 @@ function AppPoTokenSettings() {
<FormField
control={potServerPortForm.control}
name="port"
disabled={!usePotoken || useCustomCommands || isChangingPotServerPort || isStartingPotServer}
disabled={!usePotoken || isChangingPotServerPort || isStartingPotServer || isFlatpak}
render={({ field }) => (
<FormItem className="w-full">
<FormControl>
@@ -1383,7 +1385,7 @@ function AppPoTokenSettings() {
/>
<Button
type="submit"
disabled={!watchedPotServerPort || Number(watchedPotServerPort) === potServerPort || Object.keys(potServerPortFormErrors).length > 0 || !usePotoken || useCustomCommands || isChangingPotServerPort || isStartingPotServer}
disabled={!watchedPotServerPort || Number(watchedPotServerPort) === potServerPort || Object.keys(potServerPortFormErrors).length > 0 || !usePotoken || useCustomCommands || isChangingPotServerPort || isStartingPotServer || isFlatpak}
>
{isChangingPotServerPort ? (
<>
@@ -1818,7 +1820,7 @@ function AppInfoSettings() {
<TriangleAlert className="size-4 stroke-primary" />
<AlertTitle className="text-sm">Flatpak Sandbox Detected!</AlertTitle>
<AlertDescription className="text-xs">
It looks like you are running NeoDLP in a Flatpak sandbox. Some features like browser integration, desktop notifications, cookies, changing download folder, revealing completed downloads in explorer, automatic yt-dlp updates and auto-launch on startup are not available in Flatpak due to sandbox restrictions. To use these features, please install the native linux build (DEB, RPM or AUR) of NeoDLP.
It looks like you are running NeoDLP in a Flatpak sandbox. Some features like browser integration, desktop notifications, cookies, po tokens, changing download folder, revealing completed downloads in explorer, automatic yt-dlp updates and auto-launch on startup are not available in Flatpak due to sandbox restrictions. To use these features, please install the native linux build (DEB, RPM or AUR) of NeoDLP.
</AlertDescription>
</Alert>
) : isAppimage ? (

View File

@@ -2,7 +2,7 @@ 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 { Command } from "@tauri-apps/plugin-shell";
// import { Command } from "@tauri-apps/plugin-shell";
import { invoke } from "@tauri-apps/api/core";
interface FileMap {
@@ -42,43 +42,47 @@ export function useLinuxRegisterer() {
{ source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', destination: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', dir: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
];
const filesToCopyFlatpak: FileMap[] = [
// const filesToCopyFlatpak: FileMap[] = [
// { source: 'chrome.json', destination: '.config/google-chrome/NativeMessagingHosts/com.neosubhamoy.neodlp.json', dir: '.config/google-chrome/NativeMessagingHosts/', content: JSON.stringify(flatpakChromeManifestContent) },
// { source: 'chrome.json', destination: '.config/chromium/NativeMessagingHosts/com.neosubhamoy.neodlp.json', dir: '.config/chromium/NativeMessagingHosts/', content: JSON.stringify(flatpakChromeManifestContent) },
// { source: 'firefox.json', destination: '.mozilla/native-messaging-hosts/com.neosubhamoy.neodlp.json', dir: '.mozilla/native-messaging-hosts/', content: JSON.stringify(flatpakFirefoxManifestContent) },
// { source: 'neodlp-msghost', destination: '.local/bin/neodlp-msghost', dir: '.local/bin/' },
{ source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil.py', destination: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil.py', dir: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
{ source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_cli.py', destination: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_cli.py', dir: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
{ source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', destination: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', dir: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
];
// { source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil.py', destination: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil.py', dir: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
// { source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_cli.py', destination: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_cli.py', dir: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
// { source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', destination: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', dir: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
// ];
if (isFlatpak) {
for (const file of filesToCopyFlatpak) {
const sourcePath = await join(resourceDirPath, file.source);
const destinationDir = await join(homeDirPath, file.dir);
const destinationPath = await join(homeDirPath, file.destination);
const escapedContent = file.content?.replace(/'/g, `'\\''`) || '';
const copyCommand = Command.create('sh', ['-c', `mkdir -p "${destinationDir}" && cp "${sourcePath}" "${destinationPath}"`]);
const writeCommand = Command.create('sh', ['-c', `printf '%s' '${escapedContent}' > "${destinationPath}"`]);
// Skip linux registration for Flatpak
console.log('Flatpak sandbox detected! Skipping Linux registration...');
if (file.content) {
const writeOutput = await writeCommand.execute();
if (writeOutput.code === 0) {
console.log(`File ${file.destination} created successfully at ${destinationPath}`);
} else {
console.error(`Failed to create file ${file.destination} at ${destinationPath}:`, writeOutput.stderr);
return { success: false, message: 'Failed to register' };
}
} else {
const copyOutput = await copyCommand.execute();
if (copyOutput.code === 0) {
console.log(`File ${file.source} copied successfully to ${destinationPath}`);
} else {
console.error(`Failed to copy file ${file.source} to ${destinationPath}:`, copyOutput.stderr);
return { success: false, message: 'Failed to register' };
}
}
}
// for (const file of filesToCopyFlatpak) {
// const sourcePath = await join(resourceDirPath, file.source);
// const destinationDir = await join(homeDirPath, file.dir);
// const destinationPath = await join(homeDirPath, file.destination);
// const escapedContent = file.content?.replace(/'/g, `'\\''`) || '';
// const copyCommand = Command.create('sh', ['-c', `mkdir -p "${destinationDir}" && cp "${sourcePath}" "${destinationPath}"`]);
// const writeCommand = Command.create('sh', ['-c', `printf '%s' '${escapedContent}' > "${destinationPath}"`]);
// if (file.content) {
// const writeOutput = await writeCommand.execute();
// if (writeOutput.code === 0) {
// console.log(`File ${file.destination} created successfully at ${destinationPath}`);
// } else {
// console.error(`Failed to create file ${file.destination} at ${destinationPath}:`, writeOutput.stderr);
// return { success: false, message: 'Failed to register' };
// }
// } else {
// const copyOutput = await copyCommand.execute();
// if (copyOutput.code === 0) {
// console.log(`File ${file.source} copied successfully to ${destinationPath}`);
// } else {
// console.error(`Failed to copy file ${file.source} to ${destinationPath}:`, copyOutput.stderr);
// return { success: false, message: 'Failed to register' };
// }
// }
// }
} else {
for (const file of filesToCopy) {
const sourcePath = await join(resourceDirPath, file.source);

View File

@@ -20,7 +20,8 @@ export default function usePotServer() {
const isFlatpak = await invoke<boolean>('is_flatpak');
const runCommand = isFlatpak
? Command.create('sh', [
'-c', `/app/bin/neodlp-pot server --port ${port ? port.toString() : potServerPort.toString()}`
'-c',
`neodlp-pot server --port ${port ? port.toString() : potServerPort.toString()}`
])
: Command.sidecar('binaries/neodlp-pot', [
'server',