mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-03 01:42:20 +08:00
chore: 支持从源列表文件动态获取镜像源
支持从源列表文件动态获取镜像源,获取失败时默认只使用 d.store.deepinos.org.cn 该地址; 修复之前版本中设置界面“更新源”按钮无效的问题。
This commit is contained in:
parent
961d174bf7
commit
51518e4e88
@ -93,6 +93,28 @@ DownloadController::DownloadController(QObject *parent)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(parent)
|
Q_UNUSED(parent)
|
||||||
|
|
||||||
|
// 初始化默认域名
|
||||||
|
domains.clear();
|
||||||
|
domains.append("d.store.deepinos.org.cn");
|
||||||
|
|
||||||
|
QFile serverList(QDir::homePath().toUtf8() + "/.config/spark-store/server.list");
|
||||||
|
if(serverList.open(QFile::ReadOnly))
|
||||||
|
{
|
||||||
|
QStringList list = QString(serverList.readAll()).trimmed().split("\n");
|
||||||
|
qDebug() << list << list.size();
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
if (list.at(i).contains("镜像源 Download only") && i + 1 < list.size()) {
|
||||||
|
for (int j = i + 1; j < list.size(); j++) {
|
||||||
|
domains.append(list.at(j));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qDebug() << domains.size();
|
||||||
|
|
||||||
|
/*
|
||||||
domains = {
|
domains = {
|
||||||
"d1.store.deepinos.org.cn",
|
"d1.store.deepinos.org.cn",
|
||||||
"d2.store.deepinos.org.cn",
|
"d2.store.deepinos.org.cn",
|
||||||
@ -100,7 +122,8 @@ DownloadController::DownloadController(QObject *parent)
|
|||||||
"d4.store.deepinos.org.cn",
|
"d4.store.deepinos.org.cn",
|
||||||
"d5.store.deepinos.org.cn"
|
"d5.store.deepinos.org.cn"
|
||||||
};
|
};
|
||||||
this->threadNum = domains.size() > 5 ? 5 : domains.size();
|
*/
|
||||||
|
this->threadNum = domains.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadController::~DownloadController()
|
DownloadController::~DownloadController()
|
||||||
|
@ -270,6 +270,14 @@ void Widget::initConfig()
|
|||||||
{
|
{
|
||||||
ui->comboBox_server->model()->setData(ui->comboBox_server->model()->index(i, 0), QVariant(0), Qt::UserRole - 1);
|
ui->comboBox_server->model()->setData(ui->comboBox_server->model()->index(i, 0), QVariant(0), Qt::UserRole - 1);
|
||||||
}
|
}
|
||||||
|
if(ui->comboBox_server->itemText(i) == "镜像源 Download only")
|
||||||
|
{
|
||||||
|
for(int j = i; j < ui->comboBox_server->count(); j++)
|
||||||
|
{
|
||||||
|
ui->comboBox_server->model()->setData(ui->comboBox_server->model()->index(j, 0), QVariant(0), Qt::UserRole - 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1012,7 +1020,7 @@ void Widget::on_comboBox_server_currentIndexChanged(const QString &arg1)
|
|||||||
|
|
||||||
if(configCanSave)
|
if(configCanSave)
|
||||||
{
|
{
|
||||||
ui->label_setting1->show();
|
// ui->label_setting1->show();
|
||||||
QSettings *setConfig = new QSettings(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
QSettings *setConfig = new QSettings(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||||
setConfig->setValue("server/choose", arg1);
|
setConfig->setValue("server/choose", arg1);
|
||||||
}
|
}
|
||||||
@ -1051,6 +1059,14 @@ void Widget::on_pushButton_updateServer_clicked()
|
|||||||
{
|
{
|
||||||
ui->comboBox_server->model()->setData(ui->comboBox_server->model()->index(i, 0), QVariant(0), Qt::UserRole - 1);
|
ui->comboBox_server->model()->setData(ui->comboBox_server->model()->index(i, 0), QVariant(0), Qt::UserRole - 1);
|
||||||
}
|
}
|
||||||
|
if(ui->comboBox_server->itemText(i) == "镜像源 Download only")
|
||||||
|
{
|
||||||
|
for(int j = i; j < ui->comboBox_server->count(); j++)
|
||||||
|
{
|
||||||
|
ui->comboBox_server->model()->setData(ui->comboBox_server->model()->index(j, 0), QVariant(0), Qt::UserRole - 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1101,7 +1117,7 @@ void Widget::on_pushButton_updateApt_clicked()
|
|||||||
system(("chmod +x " + tmpPath + "/update.sh").c_str());
|
system(("chmod +x " + tmpPath + "/update.sh").c_str());
|
||||||
|
|
||||||
QProcess runupdate;
|
QProcess runupdate;
|
||||||
runupdate.start(QString::fromStdString("pkexec " + tmpPath + "/update.sh"), QStringList());
|
runupdate.start("pkexec", QStringList() << QString::fromStdString(tmpPath + "/update.sh"));
|
||||||
runupdate.waitForFinished();
|
runupdate.waitForFinished();
|
||||||
QString error = runupdate.readAllStandardError();
|
QString error = runupdate.readAllStandardError();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user