https://github.com/StarCitizenToolBox/app/issues/1 分流下载:增加一种快速恢复卡住的下载的方法。

This commit is contained in:
2024-01-29 22:36:04 +08:00
parent 9ab6f6056c
commit 8159e9b70e
4 changed files with 73 additions and 16 deletions

View File

@@ -36,13 +36,21 @@ class DownloaderDialogUI extends BaseUI<DownloaderDialogUIModel> {
const SizedBox(width: 24),
],
),
if (model.isP4kDownload) ...[
const SizedBox(height: 24),
Text(
"提示因网络波动若下载进度长时间卡住或速度变慢可尝试点击暂停下载之后重新点击P4K分流下载。",
style:
TextStyle(fontSize: 13, color: Colors.white.withOpacity(.7)),
),
],
],
),
actions: [
FilledButton(
child: const Padding(
padding: EdgeInsets.only(left: 8, right: 8, top: 2, bottom: 2),
child: Text("取消下载"),
child: Text("暂停下载"),
),
onPressed: () => model.doCancel()),
],

View File

@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:hive/hive.dart';
import 'package:starcitizen_doctor/base/ui_model.dart';
import 'package:starcitizen_doctor/common/rust/ffi.dart';
@@ -10,9 +11,12 @@ class DownloaderDialogUIModel extends BaseUIModel {
final String downloadUrl;
final bool showChangeSavePathDialog;
final int threadCount;
final bool isP4kDownload;
DownloaderDialogUIModel(this.fileName, this.savePath, this.downloadUrl,
{this.showChangeSavePathDialog = false, this.threadCount = 1});
{this.showChangeSavePathDialog = false,
this.threadCount = 1,
this.isP4kDownload = false});
bool isInMerging = false;
@@ -52,8 +56,15 @@ class DownloaderDialogUIModel extends BaseUIModel {
savePath = savePath.substring(0, savePath.length - fileName.length - 1);
}
final downloaderSavePath = "$savePath//$fileName.downloading";
if (isP4kDownload) {
final box = await Hive.openBox("p4k_cache");
await box.put(
"last_save_dir",
{"save_path": savePath, "file_name": fileName},
);
}
final downloaderSavePath = "$savePath//$fileName.downloading";
try {
rustFii
.startDownload(