Compare commits

..
2 Commits
Author SHA1 Message Date
Li Wei 0a4be165a5 fix: http download fail (#61) 2022-12-14 12:12:39 +08:00
levi c62867e3ef chore: fix docker-compose command 2022-12-13 15:00:32 +08:00
16 changed files with 115 additions and 56 deletions

No files matched your search

+2 -2
View File
@@ -1,5 +1,5 @@
name-template: 'v1.2.0 🌈' name-template: 'v$NEXT_PATCH_VERSION 🌈'
tag-template: 'v1.2.0' tag-template: 'v$NEXT_PATCH_VERSION'
categories: categories:
- title: '🆕 Features' - title: '🆕 Features'
labels: labels:
+1 -1
View File
@@ -62,7 +62,7 @@ services:
Use the command below to start container: Use the command below to start container:
```bash ```bash
docker compose up -d docker-compose up -d
``` ```
#### Access Gopeed #### Access Gopeed
+1 -1
View File
@@ -62,7 +62,7 @@ services:
输入以下指令启动容器: 输入以下指令启动容器:
```bash ```bash
docker compose up -d docker-compose up -d
``` ```
#### 访问服务 #### 访问服务
+1 -1
View File
@@ -151,7 +151,7 @@ func (f *Fetcher) Create(res *base.Resource, opts *base.Options) error {
return err return err
} }
if opts.Extra == nil { if opts.Extra == nil {
opts.Extra = &fhttp.ReqExtra{} opts.Extra = &fhttp.OptsExtra{}
} }
extra := opts.Extra.(*fhttp.OptsExtra) extra := opts.Extra.(*fhttp.OptsExtra)
if extra.Connections == 0 { if extra.Connections == 0 {
+9 -5
View File
@@ -142,12 +142,16 @@ func doDownloadReady(f fetcher.Fetcher, listener net.Listener, connections int,
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
opts = &base.Options{ var extra any = nil
Name: test.DownloadName, if connections > 0 {
Path: test.Dir, extra = http.OptsExtra{
Extra: http.OptsExtra{
Connections: connections, Connections: connections,
}, }
}
opts = &base.Options{
Name: test.DownloadName,
Path: test.Dir,
Extra: extra,
} }
err = fetcher.Create(res, opts) err = fetcher.Create(res, opts)
if err != nil { if err != nil {
+8 -1
View File
@@ -102,7 +102,14 @@ func (d *Downloader) Setup() error {
current := task.fetcher.Progress().TotalDownloaded() current := task.fetcher.Progress().TotalDownloaded()
task.Progress.Used = task.timer.Used() task.Progress.Used = task.timer.Used()
task.Progress.Speed = current - task.Progress.Downloaded downloaded := current - task.Progress.Downloaded
usedTime := float64(d.refreshInterval) / 1000
if downloaded == 0 {
task.Progress.Speed = int64(float64(task.Progress.Speed) / (usedTime * 1.55))
} else {
usedTime := float64(d.refreshInterval) / 1000
task.Progress.Speed = int64(float64(current-task.Progress.Downloaded) / usedTime)
}
task.Progress.Downloaded = current task.Progress.Downloaded = current
d.emit(EventKeyProgress, task) d.emit(EventKeyProgress, task)
+1 -1
View File
@@ -34,7 +34,7 @@ func (cfg *DownloaderConfig) Init() *DownloaderConfig {
} }
if cfg.RefreshInterval == 0 { if cfg.RefreshInterval == 0 {
cfg.RefreshInterval = 1000 cfg.RefreshInterval = 500
} }
return cfg return cfg
} }
+1 -1
View File
@@ -48,7 +48,7 @@ android {
// You can update the following values to match your application needs. // You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 19 minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion targetSdkVersion 29
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
} }
+3 -1
View File
@@ -15,7 +15,9 @@ class CreateTask {
this.opts, this.opts,
}); });
factory CreateTask.fromJson(Map<String, dynamic> json) => factory CreateTask.fromJson(
Map<String, dynamic> json,
) =>
_$CreateTaskFromJson(json); _$CreateTaskFromJson(json);
Map<String, dynamic> toJson() => _$CreateTaskToJson(this); Map<String, dynamic> toJson() => _$CreateTaskToJson(this);
@@ -64,12 +64,12 @@ ExtraConfigBt _$ExtraConfigBtFromJson(Map<String, dynamic> json) =>
..trackerSubscribeUrls = (json['trackerSubscribeUrls'] as List<dynamic>) ..trackerSubscribeUrls = (json['trackerSubscribeUrls'] as List<dynamic>)
.map((e) => e as String) .map((e) => e as String)
.toList() .toList()
..lastTrackerUpdateTime = json['lastTrackerUpdateTime'] == null
? null
: DateTime.parse(json['lastTrackerUpdateTime'] as String)
..subscribeTrackers = (json['subscribeTrackers'] as List<dynamic>) ..subscribeTrackers = (json['subscribeTrackers'] as List<dynamic>)
.map((e) => e as String) .map((e) => e as String)
.toList() .toList()
..lastTrackerUpdateTime = json['lastTrackerUpdateTime'] == null
? null
: DateTime.parse(json['lastTrackerUpdateTime'] as String)
..customTrackers = (json['customTrackers'] as List<dynamic>) ..customTrackers = (json['customTrackers'] as List<dynamic>)
.map((e) => e as String) .map((e) => e as String)
.toList(); .toList();
@@ -77,6 +77,7 @@ ExtraConfigBt _$ExtraConfigBtFromJson(Map<String, dynamic> json) =>
Map<String, dynamic> _$ExtraConfigBtToJson(ExtraConfigBt instance) { Map<String, dynamic> _$ExtraConfigBtToJson(ExtraConfigBt instance) {
final val = <String, dynamic>{ final val = <String, dynamic>{
'trackerSubscribeUrls': instance.trackerSubscribeUrls, 'trackerSubscribeUrls': instance.trackerSubscribeUrls,
'subscribeTrackers': instance.subscribeTrackers,
}; };
void writeNotNull(String key, dynamic value) { void writeNotNull(String key, dynamic value) {
@@ -87,7 +88,6 @@ Map<String, dynamic> _$ExtraConfigBtToJson(ExtraConfigBt instance) {
writeNotNull('lastTrackerUpdateTime', writeNotNull('lastTrackerUpdateTime',
instance.lastTrackerUpdateTime?.toIso8601String()); instance.lastTrackerUpdateTime?.toIso8601String());
val['subscribeTrackers'] = instance.subscribeTrackers;
val['customTrackers'] = instance.customTrackers; val['customTrackers'] = instance.customTrackers;
return val; return val;
} }
+13 -1
View File
@@ -2,11 +2,12 @@ import 'package:json_annotation/json_annotation.dart';
part 'options.g.dart'; part 'options.g.dart';
@JsonSerializable() @JsonSerializable(explicitToJson: true, genericArgumentFactories: true)
class Options { class Options {
String name; String name;
String path; String path;
List<int> selectFiles; List<int> selectFiles;
Map<String, dynamic>? extra;
Options({ Options({
required this.name, required this.name,
@@ -19,3 +20,14 @@ class Options {
Map<String, dynamic> toJson() => _$OptionsToJson(this); Map<String, dynamic> toJson() => _$OptionsToJson(this);
} }
@JsonSerializable()
class OptsExtraHttp {
int connections = 0;
OptsExtraHttp();
factory OptsExtraHttp.fromJson(Map<String, dynamic> json) =>
_$OptsExtraHttpFromJson(json);
Map<String, dynamic> toJson() => _$OptsExtraHttpToJson(this);
}
+24 -5
View File
@@ -11,10 +11,29 @@ Options _$OptionsFromJson(Map<String, dynamic> json) => Options(
path: json['path'] as String, path: json['path'] as String,
selectFiles: selectFiles:
(json['selectFiles'] as List<dynamic>).map((e) => e as int).toList(), (json['selectFiles'] as List<dynamic>).map((e) => e as int).toList(),
); )..extra = json['extra'] as Map<String, dynamic>?;
Map<String, dynamic> _$OptionsToJson(Options instance) => <String, dynamic>{ Map<String, dynamic> _$OptionsToJson(Options instance) {
'name': instance.name, final val = <String, dynamic>{
'path': instance.path, 'name': instance.name,
'selectFiles': instance.selectFiles, 'path': instance.path,
'selectFiles': instance.selectFiles,
};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('extra', instance.extra);
return val;
}
OptsExtraHttp _$OptsExtraHttpFromJson(Map<String, dynamic> json) =>
OptsExtraHttp()..connections = json['connections'] as int;
Map<String, dynamic> _$OptsExtraHttpToJson(OptsExtraHttp instance) =>
<String, dynamic>{
'connections': instance.connections,
}; };
+16 -2
View File
@@ -2,17 +2,31 @@ import 'package:json_annotation/json_annotation.dart';
part 'request.g.dart'; part 'request.g.dart';
@JsonSerializable() @JsonSerializable(explicitToJson: true, genericArgumentFactories: true)
class Request { class Request {
String url; String url;
Map<String, dynamic>? extra; Map<String, dynamic>? extra;
Request({ Request({
required this.url, required this.url,
this.extra,
}); });
factory Request.fromJson(Map<String, dynamic> json) => factory Request.fromJson(Map<String, dynamic> json) =>
_$RequestFromJson(json); _$RequestFromJson(json);
Map<String, dynamic> toJson() => _$RequestToJson(this); Map<String, dynamic> toJson() => _$RequestToJson(this);
} }
@JsonSerializable()
class ReqExtraHttp {
String method = 'GET';
Map<String, String> headers = {};
String body = '';
ReqExtraHttp();
factory ReqExtraHttp.fromJson(Map<String, dynamic> json) =>
_$ReqExtraHttpFromJson(json);
Map<String, dynamic> toJson() => _$ReqExtraHttpToJson(this);
}
+13 -2
View File
@@ -8,8 +8,7 @@ part of 'request.dart';
Request _$RequestFromJson(Map<String, dynamic> json) => Request( Request _$RequestFromJson(Map<String, dynamic> json) => Request(
url: json['url'] as String, url: json['url'] as String,
extra: json['extra'] as Map<String, dynamic>?, )..extra = json['extra'] as Map<String, dynamic>?;
);
Map<String, dynamic> _$RequestToJson(Request instance) { Map<String, dynamic> _$RequestToJson(Request instance) {
final val = <String, dynamic>{ final val = <String, dynamic>{
@@ -25,3 +24,15 @@ Map<String, dynamic> _$RequestToJson(Request instance) {
writeNotNull('extra', instance.extra); writeNotNull('extra', instance.extra);
return val; return val;
} }
ReqExtraHttp _$ReqExtraHttpFromJson(Map<String, dynamic> json) => ReqExtraHttp()
..method = json['method'] as String
..headers = Map<String, String>.from(json['headers'] as Map)
..body = json['body'] as String;
Map<String, dynamic> _$ReqExtraHttpToJson(ReqExtraHttp instance) =>
<String, dynamic>{
'method': instance.method,
'headers': instance.headers,
'body': instance.body,
};
+9 -9
View File
@@ -11,19 +11,19 @@ class Resource {
int size; int size;
bool range; bool range;
List<FileInfo> files; List<FileInfo> files;
Map<String, dynamic>? extra; String hash;
Resource({ Resource(
required this.req, {required this.req,
required this.name, required this.name,
required this.size, required this.size,
required this.range, required this.range,
required this.files, required this.files,
this.extra, required this.hash});
});
factory Resource.fromJson(Map<String, dynamic> json) => factory Resource.fromJson(Map<String, dynamic> json) =>
_$ResourceFromJson(json); _$ResourceFromJson(json);
Map<String, dynamic> toJson() => _$ResourceToJson(this); Map<String, dynamic> toJson() => _$ResourceToJson(this);
} }
+9 -19
View File
@@ -14,27 +14,17 @@ Resource _$ResourceFromJson(Map<String, dynamic> json) => Resource(
files: (json['files'] as List<dynamic>) files: (json['files'] as List<dynamic>)
.map((e) => FileInfo.fromJson(e as Map<String, dynamic>)) .map((e) => FileInfo.fromJson(e as Map<String, dynamic>))
.toList(), .toList(),
extra: json['extra'] as Map<String, dynamic>?, hash: json['hash'] as String,
); );
Map<String, dynamic> _$ResourceToJson(Resource instance) { Map<String, dynamic> _$ResourceToJson(Resource instance) => <String, dynamic>{
final val = <String, dynamic>{ 'req': instance.req.toJson(),
'req': instance.req.toJson(), 'name': instance.name,
'name': instance.name, 'size': instance.size,
'size': instance.size, 'range': instance.range,
'range': instance.range, 'files': instance.files.map((e) => e.toJson()).toList(),
'files': instance.files.map((e) => e.toJson()).toList(), 'hash': instance.hash,
}; };
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('extra', instance.extra);
return val;
}
FileInfo _$FileInfoFromJson(Map<String, dynamic> json) => FileInfo( FileInfo _$FileInfoFromJson(Map<String, dynamic> json) => FileInfo(
name: json['name'] as String, name: json['name'] as String,