Skip to content

Commit

Permalink
moved logic of finding tmpdir to function
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehmcc committed Aug 13, 2022
1 parent c910325 commit 8a95fc9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
5 changes: 1 addition & 4 deletions lib/generic/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import 'package:vup/utils/ffmpeg/io.dart';
import 'package:xdg_directories/xdg_directories.dart';

Future<void> initAppGeneric({required bool isRunningInFlutterMode}) async {
Directory tempDir = Directory('/tmp');
if(configHome.toString().contains('app.vup.Vup') && runtimeDir != null){
tempDir = Directory(join(runtimeDir!.path, 'app', 'app.vup.Vup'));
}
final tempDir = Directory('/tmp');

vupTempDir = join(tempDir.path, 'vup');

Expand Down
6 changes: 2 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -105,10 +106,7 @@ Future<void> initApp() async {
'vup',
);

Directory tempDir = await getTemporaryDirectory();
if(configHome.toString().contains('app.vup.Vup') && runtimeDir != null){
tempDir = Directory(join(runtimeDir!.path, 'app', 'app.vup.Vup'));
}
final tempDir = await getTempDir();
vupTempDir = join(tempDir.path, 'vup');

vupDataDir = join(dataHome.path, 'vup');
Expand Down
6 changes: 2 additions & 4 deletions lib/service/jellyfin_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:xdg_directories/xdg_directories.dart';
import 'package:subtitle/subtitle.dart';

Expand Down Expand Up @@ -2099,10 +2100,7 @@ class JellyfinServerService extends VupService {
});

app.get('/playback/bitratetest', (req, res) async {
String tmpString = 'tmp';
if(configHome.toString().contains('app.vup.Vup') && runtimeDir != null){
tmpString = join(runtimeDir!.path, 'app', 'app.vup.Vup');
}
String tmpString = (await getTempDir()).path;
final file = File(join(tmpString, Uuid().v4()));
file.createSync(recursive: true);
file.writeAsBytesSync(
Expand Down
13 changes: 13 additions & 0 deletions lib/utils/temp_dir.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'dart:io';

import 'package:path_provider/path_provider.dart';
import 'package:xdg_directories/xdg_directories.dart';
import 'package:path/path.dart';

Future<Directory> getTempDir() async {
Directory tmpDir = await getTemporaryDirectory();
if(Platform.isLinux && configHome.toString().contains('app.vup.Vup') && runtimeDir != null){
tmpDir = Directory(join(runtimeDir!.path, 'app', 'app.vup.Vup'));
}
return tmpDir;
}

0 comments on commit 8a95fc9

Please sign in to comment.