mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-16 21:33:41 +00:00
fix: incorrect storage path in linux (#270)
This commit is contained in:
9 files changed
+158
-79
No files matched your search
+71
-56
@@ -7,6 +7,10 @@ on:
|
|||||||
description: 'Build platform'
|
description: 'Build platform'
|
||||||
required: true
|
required: true
|
||||||
default: 'all'
|
default: 'all'
|
||||||
|
channel:
|
||||||
|
description: 'Snap channel'
|
||||||
|
required: true
|
||||||
|
default: 'stable'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GO_VERSION: "1.19"
|
GO_VERSION: "1.19"
|
||||||
@@ -208,7 +212,7 @@ jobs:
|
|||||||
overwrite: true
|
overwrite: true
|
||||||
build-linux:
|
build-linux:
|
||||||
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'linux' }}
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'linux' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-20.04
|
||||||
needs: [ get-release ]
|
needs: [ get-release ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -221,10 +225,6 @@ jobs:
|
|||||||
- run: |
|
- run: |
|
||||||
sudo apt-get update -y
|
sudo apt-get update -y
|
||||||
sudo apt-get install -y ninja-build libgtk-3-dev libayatana-appindicator3-dev
|
sudo apt-get install -y ninja-build libgtk-3-dev libayatana-appindicator3-dev
|
||||||
- name: Setup LXD
|
|
||||||
uses: canonical/[email protected]
|
|
||||||
with:
|
|
||||||
channel: latest/stable
|
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ needs.get-release.outputs.tag_name }}
|
VERSION: ${{ needs.get-release.outputs.tag_name }}
|
||||||
@@ -237,41 +237,45 @@ jobs:
|
|||||||
# Build portable
|
# Build portable
|
||||||
tar -C build/linux/x64/release/bundle -czaf build/dist/Gopeed-$VERSION-linux-amd64-portable.tar.gz ./
|
tar -C build/linux/x64/release/bundle -czaf build/dist/Gopeed-$VERSION-linux-amd64-portable.tar.gz ./
|
||||||
|
|
||||||
|
|
||||||
# Build deb package
|
# Build deb package
|
||||||
mkdir -p debian/gui
|
mkdir -p debian/gopeed/opt/gopeed
|
||||||
cp assets/icon/icon_1024.png debian/gui/gopeed.png
|
mkdir -p debian/gopeed/usr/share/applications
|
||||||
cat>debian/debian.yaml<<EOF
|
mkdir -p debian/gopeed/usr/share/icons/hicolor/scalable/apps
|
||||||
flutter_app:
|
mkdir -p debian/gopeed/DEBIAN
|
||||||
command: gopeed
|
|
||||||
arch: x64
|
cp -r build/linux/x64/release/bundle/* debian/gopeed/opt/gopeed/
|
||||||
parent: /usr/local/bin
|
cp assets/icon/icon_512.png debian/gopeed/usr/share/icons/hicolor/scalable/apps/gopeed.png
|
||||||
control:
|
|
||||||
Package: gopeed
|
cat>debian/gopeed/DEBIAN/postinst<<EOF
|
||||||
Version: ${VERSION:1}
|
#!/bin/bash
|
||||||
Architecture: amd64
|
ln -sf /opt/gopeed/gopeed /usr/local/bin/gopeed
|
||||||
Essential: no
|
|
||||||
Priority: optional
|
|
||||||
Depends:
|
|
||||||
Maintainer: monkeyWie
|
|
||||||
Description: High speed downloader that supports all platforms.
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat>debian/gui/gopeed.desktop<<EOF
|
cat>debian/gopeed/DEBIAN/postrm<<EOF
|
||||||
[Desktop Entry]
|
#!/bin/bash
|
||||||
Name=Gopeed
|
rm -f /usr/local/bin/gopeed
|
||||||
GenericName=Downloader Manager
|
current_user=\$(logname)
|
||||||
Comment=High speed downloader that supports all platforms.
|
rm -rf /home/\$current_user/.local/share/com.gopeed
|
||||||
Terminal=false
|
|
||||||
Type=Application
|
|
||||||
Categories=Utility
|
|
||||||
Keywords=HTTP;Bittorrent;Downloader;
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
dart pub global activate flutter_to_debian
|
chmod 0755 debian/gopeed/DEBIAN/postinst
|
||||||
flutter_to_debian
|
chmod 0755 debian/gopeed/DEBIAN/postrm
|
||||||
mv debian/packages/gopeed*.deb build/dist/Gopeed-$VERSION-linux-amd64.deb
|
|
||||||
|
|
||||||
|
cat>debian/gopeed/DEBIAN/control<<EOF
|
||||||
|
Package: gopeed
|
||||||
|
Version: ${VERSION:1}
|
||||||
|
Architecture: amd64
|
||||||
|
Essential: no
|
||||||
|
Priority: optional
|
||||||
|
Depends:
|
||||||
|
Maintainer: monkeyWie
|
||||||
|
Description: High speed downloader that supports all platforms.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cp linux/gopeed.desktop debian/gopeed/usr/share/applications/gopeed.desktop
|
||||||
|
|
||||||
|
dpkg-deb --build debian/gopeed
|
||||||
|
mv debian/gopeed.deb build/dist/Gopeed-$VERSION-linux-amd64.deb
|
||||||
|
|
||||||
# Build AppImage
|
# Build AppImage
|
||||||
sudo apt-get -y install libfuse2
|
sudo apt-get -y install libfuse2
|
||||||
@@ -335,12 +339,38 @@ jobs:
|
|||||||
EOF
|
EOF
|
||||||
./appimage-builder --skip-tests --recipe AppImageBuilder.yml
|
./appimage-builder --skip-tests --recipe AppImageBuilder.yml
|
||||||
mv Gopeed-*-x86_64.AppImage build/dist/Gopeed-$VERSION-linux-amd64.AppImage
|
mv Gopeed-*-x86_64.AppImage build/dist/Gopeed-$VERSION-linux-amd64.AppImage
|
||||||
|
- name: Upload
|
||||||
|
uses: shogo82148/actions-upload-release-asset@v1
|
||||||
|
with:
|
||||||
|
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
||||||
|
asset_path: ui/flutter/build/dist/*
|
||||||
|
overwrite: true
|
||||||
|
build-snap:
|
||||||
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'snap' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ get-release ]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||||
|
- name: Setup LXD
|
||||||
|
uses: canonical/[email protected]
|
||||||
|
with:
|
||||||
|
channel: latest/stable
|
||||||
|
- name: Build
|
||||||
|
env:
|
||||||
|
VERSION: ${{ needs.get-release.outputs.tag_name }}
|
||||||
|
run: |
|
||||||
|
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/GopeedLab/gopeed/bind/desktop
|
||||||
|
cd ui/flutter
|
||||||
|
|
||||||
# Build snap
|
|
||||||
sudo snap install snapcraft --classic
|
sudo snap install snapcraft --classic
|
||||||
rm -rf build/linux
|
|
||||||
mkdir -p snap/gui
|
mkdir -p snap/gui
|
||||||
cp assets/icon/icon_1024.png snap/gui/gopeed.png
|
cp assets/icon/icon_512.png snap/gui/gopeed.png
|
||||||
|
|
||||||
cat>snap/snapcraft.yaml<<EOF
|
cat>snap/snapcraft.yaml<<EOF
|
||||||
name: gopeed
|
name: gopeed
|
||||||
@@ -375,34 +405,19 @@ jobs:
|
|||||||
source: .
|
source: .
|
||||||
plugin: flutter
|
plugin: flutter
|
||||||
stage-packages:
|
stage-packages:
|
||||||
|
- libgtk-3-dev
|
||||||
- libayatana-appindicator3-dev
|
- libayatana-appindicator3-dev
|
||||||
flutter-target: lib/main.dart
|
flutter-target: lib/main.dart
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat>snap/gui/gopeed.desktop<<EOF
|
cp linux/gopeed.desktop snap/gui/gopeed.desktop
|
||||||
[Desktop Entry]
|
sed -i 's/Icon=gopeed/Icon=\${SNAP}\/meta\/gui\/gopeed.png/g' snap/gui/gopeed.desktop
|
||||||
Name=Gopeed
|
|
||||||
GenericName=Downloader Manager
|
|
||||||
Comment=High speed downloader that supports all platforms.
|
|
||||||
Exec=gopeed
|
|
||||||
Icon=\${SNAP}/meta/gui/gopeed.png
|
|
||||||
Terminal=false
|
|
||||||
Type=Application
|
|
||||||
Categories=Utility
|
|
||||||
Keywords=HTTP;Bittorrent;Downloader;
|
|
||||||
EOF
|
|
||||||
|
|
||||||
snapcraft --use-lxd
|
snapcraft --use-lxd
|
||||||
|
|
||||||
# Snapcraft login
|
# Snapcraft login
|
||||||
export SNAPCRAFT_STORE_CREDENTIALS=${{ secrets.SNAP_STORE_LOGIN }}
|
export SNAPCRAFT_STORE_CREDENTIALS=${{ secrets.SNAP_STORE_LOGIN }}
|
||||||
snapcraft upload --release=stable gopeed_${VERSION:1}_amd64.snap
|
snapcraft upload --release=${{ github.event.inputs.channel }} gopeed_${VERSION:1}_amd64.snap
|
||||||
- name: Upload
|
|
||||||
uses: shogo82148/actions-upload-release-asset@v1
|
|
||||||
with:
|
|
||||||
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
|
||||||
asset_path: ui/flutter/build/dist/*
|
|
||||||
overwrite: true
|
|
||||||
build-android:
|
build-android:
|
||||||
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'android' }}
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'android' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
@@ -209,6 +209,10 @@ class AppController extends GetxController with WindowListener, TrayListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initForegroundTask() async {
|
Future<void> _initForegroundTask() async {
|
||||||
|
if (!Util.isMobile()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FlutterForegroundTask.init(
|
FlutterForegroundTask.init(
|
||||||
androidNotificationOptions: AndroidNotificationOptions(
|
androidNotificationOptions: AndroidNotificationOptions(
|
||||||
channelId: 'gopeed_service',
|
channelId: 'gopeed_service',
|
||||||
@@ -269,13 +273,8 @@ class AppController extends GetxController with WindowListener, TrayListener {
|
|||||||
_defaultStartConfig!.address = "127.0.0.1:0";
|
_defaultStartConfig!.address = "127.0.0.1:0";
|
||||||
} else {
|
} else {
|
||||||
_defaultStartConfig!.network = "unix";
|
_defaultStartConfig!.network = "unix";
|
||||||
if (Util.isDesktop()) {
|
_defaultStartConfig!.address =
|
||||||
_defaultStartConfig!.address = unixSocketPath;
|
"${(await getTemporaryDirectory()).path}/$unixSocketPath";
|
||||||
}
|
|
||||||
if (Util.isMobile()) {
|
|
||||||
_defaultStartConfig!.address =
|
|
||||||
"${(await getTemporaryDirectory()).path}/$unixSocketPath";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_defaultStartConfig!.apiToken = '';
|
_defaultStartConfig!.apiToken = '';
|
||||||
return _defaultStartConfig!;
|
return _defaultStartConfig!;
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import "libgopeed_boot_stub.dart"
|
|||||||
if (dart.library.io) 'entry/libgopeed_boot_native.dart';
|
if (dart.library.io) 'entry/libgopeed_boot_native.dart';
|
||||||
|
|
||||||
abstract class LibgopeedBoot {
|
abstract class LibgopeedBoot {
|
||||||
static const unixSocketPath = 'gopeed.sock';
|
|
||||||
|
|
||||||
static LibgopeedBoot? _instance;
|
static LibgopeedBoot? _instance;
|
||||||
|
|
||||||
static LibgopeedBoot get instance {
|
static LibgopeedBoot get instance {
|
||||||
|
|||||||
@@ -37,11 +37,13 @@ Future<void> init() async {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Util.isWeb()) {
|
||||||
|
await Util.initStorageDir();
|
||||||
|
}
|
||||||
|
initLogger();
|
||||||
|
|
||||||
final controller = Get.put(AppController());
|
final controller = Get.put(AppController());
|
||||||
try {
|
try {
|
||||||
if (!Util.isWeb()) {
|
|
||||||
await Util.initStorageDir();
|
|
||||||
}
|
|
||||||
await controller.loadStartConfig();
|
await controller.loadStartConfig();
|
||||||
final startCfg = controller.startConfig.value;
|
final startCfg = controller.startConfig.value;
|
||||||
controller.runningPort.value = await LibgopeedBoot.instance.start(startCfg);
|
controller.runningPort.value = await LibgopeedBoot.instance.start(startCfg);
|
||||||
|
|||||||
@@ -1,18 +1,24 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
|
import 'package:path/path.dart' as path;
|
||||||
import 'util.dart';
|
import 'util.dart';
|
||||||
|
|
||||||
final logger = Logger(
|
late final Logger logger;
|
||||||
filter: ProductionFilter(),
|
|
||||||
printer: SimplePrinter(printTime: true, colors: false),
|
|
||||||
output: buildOutput(),
|
|
||||||
);
|
|
||||||
|
|
||||||
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 is debug mode, don't log to file
|
||||||
if (!kDebugMode && Util.isDesktop()) {
|
if (!kDebugMode && Util.isDesktop()) {
|
||||||
const logDirPath = 'logs';
|
final logDirPath = path.join(Util.getStorageDir(), 'logs');
|
||||||
var logDir = Directory(logDirPath);
|
var logDir = Directory(logDirPath);
|
||||||
if (!logDir.existsSync()) {
|
if (!logDir.existsSync()) {
|
||||||
logDir.createSync();
|
logDir.createSync();
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
|
import 'log_util.dart';
|
||||||
|
|
||||||
class Util {
|
class Util {
|
||||||
static String? _storageDir;
|
static String? _storageDir;
|
||||||
|
|
||||||
@@ -55,6 +57,16 @@ class Util {
|
|||||||
storageDir = (await getExternalStorageDirectory())?.path ?? storageDir;
|
storageDir = (await getExternalStorageDirectory())?.path ?? storageDir;
|
||||||
} else if (Platform.isIOS) {
|
} else if (Platform.isIOS) {
|
||||||
storageDir = (await getLibraryDirectory()).path;
|
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;
|
_storageDir = storageDir;
|
||||||
}
|
}
|
||||||
@@ -63,10 +75,6 @@ class Util {
|
|||||||
return _storageDir!;
|
return _storageDir!;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getStorageAsset(String asset) {
|
|
||||||
return path.join(getStorageDir(), asset);
|
|
||||||
}
|
|
||||||
|
|
||||||
static isAndroid() {
|
static isAndroid() {
|
||||||
return !kIsWeb && Platform.isAndroid;
|
return !kIsWeb && Platform.isAndroid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<component type="desktop-application">
|
||||||
|
<id>com.gopeed.Gopeed</id>
|
||||||
|
|
||||||
|
<name>Gopeed</name>
|
||||||
|
<summary>High speed downloader that supports all platforms.</summary>
|
||||||
|
<url type="homepage">https://gopeed.com</url>
|
||||||
|
<url type="bugtracker">https://github.com/GopeedLab/gopeed/issues</url>
|
||||||
|
<url type="donation">https://docs.gopeed.com/donate.html</url>
|
||||||
|
<url type="translate">https://github.com/GopeedLab/gopeed/blob/main/CONTRIBUTING.md#translation</url>
|
||||||
|
|
||||||
|
|
||||||
|
<metadata_license>MIT</metadata_license>
|
||||||
|
<project_license>GPL-3.0-only</project_license>
|
||||||
|
<developer_name>monkeyWie</developer_name>
|
||||||
|
|
||||||
|
<supports>
|
||||||
|
<control>pointing</control>
|
||||||
|
<control>keyboard</control>
|
||||||
|
<control>touch</control>
|
||||||
|
</supports>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
Gopeed (full name Go Speed), a high-speed downloader developed by <code>Golang</code> + <code>Flutter</code>, supports (HTTP, BitTorrent, Magnet) protocol, and supports all platforms.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<content_rating type="oars-1.1"/>
|
||||||
|
|
||||||
|
<launchable type="desktop-id">com.gopeed.Gopeed.desktop</launchable>
|
||||||
|
<screenshots>
|
||||||
|
<screenshot type="default">
|
||||||
|
<image>https://raw.githubusercontent.com/GopeedLab/gopeed/v1.4.4/_docs/img/ui-demo.png</image>
|
||||||
|
</screenshot>
|
||||||
|
</screenshots>
|
||||||
|
|
||||||
|
<releases>
|
||||||
|
<release version="1.4.4" date="2023-11-09"/>
|
||||||
|
</releases>
|
||||||
|
</component>
|
||||||
@@ -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;
|
||||||
Reference in new issue
Block a user