diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4b805de2..c2cefe34 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,10 @@ on: description: 'Build platform' required: true default: 'all' + channel: + description: 'Snap channel' + required: true + default: 'stable' env: GO_VERSION: "1.19" @@ -208,7 +212,7 @@ jobs: overwrite: true build-linux: if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'linux' }} - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: [ get-release ] steps: - uses: actions/checkout@v3 @@ -221,10 +225,6 @@ jobs: - run: | sudo apt-get update -y sudo apt-get install -y ninja-build libgtk-3-dev libayatana-appindicator3-dev - - name: Setup LXD - uses: canonical/setup-lxd@v0.1.1 - with: - channel: latest/stable - name: Build env: VERSION: ${{ needs.get-release.outputs.tag_name }} @@ -237,41 +237,45 @@ jobs: # Build portable tar -C build/linux/x64/release/bundle -czaf build/dist/Gopeed-$VERSION-linux-amd64-portable.tar.gz ./ - # Build deb package - mkdir -p debian/gui - cp assets/icon/icon_1024.png debian/gui/gopeed.png - cat>debian/debian.yaml<debian/gui/gopeed.desktop<debian/gopeed/DEBIAN/postinst<debian/gopeed/DEBIAN/postrm<debian/gopeed/DEBIAN/control<snap/snapcraft.yaml<snap/gui/gopeed.desktop< _initForegroundTask() async { + if (!Util.isMobile()) { + return; + } + FlutterForegroundTask.init( androidNotificationOptions: AndroidNotificationOptions( channelId: 'gopeed_service', @@ -269,13 +273,8 @@ class AppController extends GetxController with WindowListener, TrayListener { _defaultStartConfig!.address = "127.0.0.1:0"; } else { _defaultStartConfig!.network = "unix"; - if (Util.isDesktop()) { - _defaultStartConfig!.address = unixSocketPath; - } - if (Util.isMobile()) { - _defaultStartConfig!.address = - "${(await getTemporaryDirectory()).path}/$unixSocketPath"; - } + _defaultStartConfig!.address = + "${(await getTemporaryDirectory()).path}/$unixSocketPath"; } _defaultStartConfig!.apiToken = ''; return _defaultStartConfig!; diff --git a/ui/flutter/lib/core/libgopeed_boot.dart b/ui/flutter/lib/core/libgopeed_boot.dart index 53d7d370..98bf3dc8 100644 --- a/ui/flutter/lib/core/libgopeed_boot.dart +++ b/ui/flutter/lib/core/libgopeed_boot.dart @@ -4,8 +4,6 @@ import "libgopeed_boot_stub.dart" if (dart.library.io) 'entry/libgopeed_boot_native.dart'; abstract class LibgopeedBoot { - static const unixSocketPath = 'gopeed.sock'; - static LibgopeedBoot? _instance; static LibgopeedBoot get instance { diff --git a/ui/flutter/lib/main.dart b/ui/flutter/lib/main.dart index b1c4164b..8ca0359b 100644 --- a/ui/flutter/lib/main.dart +++ b/ui/flutter/lib/main.dart @@ -37,11 +37,13 @@ Future init() async { }); } + if (!Util.isWeb()) { + await Util.initStorageDir(); + } + initLogger(); + final controller = Get.put(AppController()); try { - if (!Util.isWeb()) { - await Util.initStorageDir(); - } await controller.loadStartConfig(); final startCfg = controller.startConfig.value; controller.runningPort.value = await LibgopeedBoot.instance.start(startCfg); diff --git a/ui/flutter/lib/util/log_util.dart b/ui/flutter/lib/util/log_util.dart index 92af13a7..9a1ac689 100644 --- a/ui/flutter/lib/util/log_util.dart +++ b/ui/flutter/lib/util/log_util.dart @@ -1,18 +1,24 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:logger/logger.dart'; +import 'package:path/path.dart' as path; import 'util.dart'; -final logger = Logger( - filter: ProductionFilter(), - printer: SimplePrinter(printTime: true, colors: false), - output: buildOutput(), -); +late final Logger logger; -buildOutput() { +initLogger() { + // if is debug mode, don't log to file + logger = Logger( + filter: ProductionFilter(), + printer: SimplePrinter(printTime: true, colors: false), + output: _buildOutput(), + ); +} + +_buildOutput() { // if is debug mode, don't log to file if (!kDebugMode && Util.isDesktop()) { - const logDirPath = 'logs'; + final logDirPath = path.join(Util.getStorageDir(), 'logs'); var logDir = Directory(logDirPath); if (!logDir.existsSync()) { logDir.createSync(); diff --git a/ui/flutter/lib/util/util.dart b/ui/flutter/lib/util/util.dart index 8304dee3..8f150ce2 100644 --- a/ui/flutter/lib/util/util.dart +++ b/ui/flutter/lib/util/util.dart @@ -6,6 +6,8 @@ import 'package:flutter/foundation.dart'; import 'package:path_provider/path_provider.dart'; import 'package:path/path.dart' as path; +import 'log_util.dart'; + class Util { static String? _storageDir; @@ -55,6 +57,16 @@ class Util { storageDir = (await getExternalStorageDirectory())?.path ?? storageDir; } else if (Platform.isIOS) { storageDir = (await getLibraryDirectory()).path; + } else if (Util.isLinux()) { + storageDir = File(Platform.resolvedExecutable).parent.path; + // check has write permission, if not, fallback to application support dir + try { + final testFile = File(path.join(storageDir, ".test")); + await testFile.writeAsString("test"); + await testFile.delete(); + } catch (e) { + storageDir = (await getApplicationSupportDirectory()).path; + } } _storageDir = storageDir; } @@ -63,10 +75,6 @@ class Util { return _storageDir!; } - static String getStorageAsset(String asset) { - return path.join(getStorageDir(), asset); - } - static isAndroid() { return !kIsWeb && Platform.isAndroid; } diff --git a/ui/flutter/linux/com.gopeed.Gopeed.metainfo.xml b/ui/flutter/linux/com.gopeed.Gopeed.metainfo.xml new file mode 100644 index 00000000..3dbf8420 --- /dev/null +++ b/ui/flutter/linux/com.gopeed.Gopeed.metainfo.xml @@ -0,0 +1,41 @@ + + + com.gopeed.Gopeed + + Gopeed + High speed downloader that supports all platforms. + https://gopeed.com + https://github.com/GopeedLab/gopeed/issues + https://docs.gopeed.com/donate.html + https://github.com/GopeedLab/gopeed/blob/main/CONTRIBUTING.md#translation + + + MIT + GPL-3.0-only + monkeyWie + + + pointing + keyboard + touch + + + +

+ Gopeed (full name Go Speed), a high-speed downloader developed by Golang + Flutter, supports (HTTP, BitTorrent, Magnet) protocol, and supports all platforms. +

+
+ + + + com.gopeed.Gopeed.desktop + + + https://raw.githubusercontent.com/GopeedLab/gopeed/v1.4.4/_docs/img/ui-demo.png + + + + + + +
\ No newline at end of file diff --git a/ui/flutter/linux/gopeed.desktop b/ui/flutter/linux/gopeed.desktop new file mode 100644 index 00000000..2e35e9c2 --- /dev/null +++ b/ui/flutter/linux/gopeed.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=Gopeed +GenericName=Downloader Manager +Comment=High speed downloader that supports all platforms. +Exec=gopeed +Icon=gopeed +Terminal=false +Type=Application +Categories=Utility +Keywords=HTTP;Bittorrent;Downloader; \ No newline at end of file