From c207269fd7eb20a96b40851fe6f2dadd1153c204 Mon Sep 17 00:00:00 2001 From: Theo Diamantidis Date: Sun, 22 Oct 2023 03:02:22 +0300 Subject: [PATCH 1/2] fix(integration): resolve desktop file before moving; handle bad desktop file in disintegrate --- .../features/home/data/appimage_tools_repository.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/features/home/data/appimage_tools_repository.dart b/lib/src/features/home/data/appimage_tools_repository.dart index 977ab4f..7fb602e 100644 --- a/lib/src/features/home/data/appimage_tools_repository.dart +++ b/lib/src/features/home/data/appimage_tools_repository.dart @@ -68,7 +68,7 @@ class AppimageToolsRepository { .listSync() .firstWhere((element) => p.extension(element.path) == ".desktop"); await desktopFile - .moveFile(_localPathService.applicationsDir + desktopfilename); + .moveResolvedFile(_localPathService.applicationsDir + desktopfilename); String execPath = (await Process.run( "grep", [ @@ -150,7 +150,7 @@ class AppimageToolsRepository { FileSystemEntity file, ) async { // Delete Icons - String iconName = (await Process.run( + String? iconName = (await Process.run( "grep", [ "^Icon=", @@ -160,8 +160,9 @@ class AppimageToolsRepository { workingDirectory: _localPathService.applicationsDir, )) .stdout - .split("=")[1] - .trim(); + .split("=") + .elementAtOrNull(1) + ?.trim(); for (var icon in Directory(_localPathService.iconsDir).listSync(recursive: true)) { if (p.basenameWithoutExtension(icon.path) == iconName) { From e5c2a63b8f8bc5181da5a4382de9c4727007001c Mon Sep 17 00:00:00 2001 From: Theo Diamantidis Date: Mon, 23 Oct 2023 01:06:51 +0300 Subject: [PATCH 2/2] fix: replace elementAtOrNull with try-catch to fix method not found error --- .../home/data/appimage_tools_repository.dart | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/src/features/home/data/appimage_tools_repository.dart b/lib/src/features/home/data/appimage_tools_repository.dart index 7fb602e..01a07c8 100644 --- a/lib/src/features/home/data/appimage_tools_repository.dart +++ b/lib/src/features/home/data/appimage_tools_repository.dart @@ -150,19 +150,22 @@ class AppimageToolsRepository { FileSystemEntity file, ) async { // Delete Icons - String? iconName = (await Process.run( - "grep", - [ - "^Icon=", - _localPathService.applicationsDir + content[index] + ".desktop", - ], - runInShell: true, - workingDirectory: _localPathService.applicationsDir, - )) - .stdout - .split("=") - .elementAtOrNull(1) - ?.trim(); + String? iconName; + try { + iconName = (await Process.run( + "grep", + [ + "^Icon=", + _localPathService.applicationsDir + content[index] + ".desktop", + ], + runInShell: true, + workingDirectory: _localPathService.applicationsDir, + )) + .stdout + .split("=")[1] + .trim(); + } on RangeError {} + for (var icon in Directory(_localPathService.iconsDir).listSync(recursive: true)) { if (p.basenameWithoutExtension(icon.path) == iconName) {