diff --git a/lib/main.dart b/lib/main.dart index e8f7989..ce55274 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,6 +25,7 @@ import 'package:vup/utils/ffmpeg/flutter.dart'; import 'package:vup/utils/ffmpeg/io.dart'; import 'package:vup/utils/special_titles.dart'; import 'package:vup/utils/strings.dart'; +import 'package:vup/utils/temp_dir.dart'; import 'package:vup/view/tab.dart'; import 'package:vup/widget/app_bar_wrapper.dart'; import 'package:vup/widget/vup_logo.dart'; @@ -105,7 +106,7 @@ Future initApp() async { 'vup', ); - final tempDir = await getTemporaryDirectory(); + final tempDir = await getTempDir(); vupTempDir = join(tempDir.path, 'vup'); vupDataDir = join(dataHome.path, 'vup'); diff --git a/lib/service/jellyfin_server.dart b/lib/service/jellyfin_server.dart index bd4d6b7..d7b216a 100644 --- a/lib/service/jellyfin_server.dart +++ b/lib/service/jellyfin_server.dart @@ -17,6 +17,7 @@ import 'package:vup/service/jellyfin_server/statistics.dart'; import 'package:vup/service/rich_status_service.dart'; import 'package:vup/service/web_server/serve_chunked_file.dart'; import 'package:alfred/src/type_handlers/websocket_type_handler.dart'; +import 'package:vup/utils/temp_dir.dart'; import 'package:subtitle/subtitle.dart'; import 'package:archive2/archive_io.dart'; @@ -2098,7 +2099,8 @@ class JellyfinServerService extends VupService { }); app.get('/playback/bitratetest', (req, res) async { - final file = File('/tmp/${Uuid().v4()}'); + String tmpString = (await getTempDir()).path; + final file = File(join(tmpString, const Uuid().v4())); file.createSync(recursive: true); file.writeAsBytesSync( Uint8List(int.parse(req.requestedUri.queryParameters['size']!))); diff --git a/lib/utils/temp_dir.dart b/lib/utils/temp_dir.dart new file mode 100644 index 0000000..d188f0b --- /dev/null +++ b/lib/utils/temp_dir.dart @@ -0,0 +1,15 @@ +import 'dart:io'; + +import 'package:path_provider/path_provider.dart'; +import 'package:xdg_directories/xdg_directories.dart'; +import 'package:path/path.dart'; + +bool get isRunningAsFlatpak => configHome.path.contains('app.vup.Vup'); + +Future getTempDir() async { + Directory tmpDir = await getTemporaryDirectory(); + if (Platform.isLinux && isRunningAsFlatpak && runtimeDir != null) { + tmpDir = Directory(join(runtimeDir!.path, 'app', 'app.vup.Vup')); + } + return tmpDir; +} diff --git a/lib/view/sidebar.dart b/lib/view/sidebar.dart index a5f2062..c003eb9 100644 --- a/lib/view/sidebar.dart +++ b/lib/view/sidebar.dart @@ -16,6 +16,7 @@ import 'package:vup/page/settings.dart'; import 'package:vup/utils/ffmpeg/base.dart'; import 'package:vup/utils/ffmpeg_installer.dart'; import 'package:vup/utils/show_portal_dialog.dart'; +import 'package:vup/utils/temp_dir.dart'; import 'package:vup/view/setup_sync_dialog.dart'; import 'package:vup/widget/sidebar_shortcut.dart'; import 'package:vup/widget/user.dart'; @@ -829,7 +830,7 @@ MimeType=x-scheme-handler/vup; ], ), ), - if (isInstallationAvailable) + if (isInstallationAvailable && !isRunningAsFlatpak) Container( decoration: BoxDecoration( color: SkyColors.warning,