fix: 校验 serverlist 有效性

This commit is contained in:
2022-12-27 10:54:30 +08:00
parent 30b65350ca
commit e344b16aa0
4 changed files with 51 additions and 34 deletions
+21 -4
View File
@@ -9,6 +9,7 @@
#define TMP_PATH "/tmp/spark-store"
#define DEFAULT_SERVER_URL "https://cdn.d.store.deepinos.org.cn/"
#define DEFAULT_CHECK_DOMAIN "deepinos"
bool SettingsPage::isdownload = false;
@@ -55,7 +56,11 @@ void SettingsPage::readServerList()
// 创建 QTextStream 对象
QTextStream textStream(&file);
if (!textStream.readAll().contains(DEFAULT_CHECK_DOMAIN)) // 校验配置文件有效性
{
return;
}
textStream.seek(0); // 回到开头
QString lineData = textStream.readLine(); // 读取文件的第一行
ui->comboBox_server->addItem(lineData);
while (!lineData.isNull())
@@ -106,11 +111,23 @@ void SettingsPage::on_pushButton_updateServer_clicked()
QtConcurrent::run([=]()
{
ui->pushButton_updateServer->setEnabled(false);
ui->comboBox_server->clear();
QFile::remove(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/server.list");
system("curl -o " + QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation).toUtf8() + "/server.list https://d.store.deepinos.org.cn/store/server-and-mirror.list");
auto updateSuccess = system("curl -o " + QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation).toUtf8() + "/server.list https://d.store.deepinos.org.cn/store/server-and-mirror.list");
qDebug() << "Update serverlist status:" << updateSuccess;
if (updateSuccess != 0) // 更新失败不换服务器配置
{
QFile file(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/server.list");
if (file.exists())
{
file.remove();
}
// FIXME: 向用户提示更新失败
ui->pushButton_updateServer->setEnabled(true);
return;
}
ui->comboBox_server->clear();
ui->pushButton_updateServer->setEnabled(true);
readServerList();
ui->comboBox_server->setCurrentIndex(0); });
+10 -10
View File
@@ -441,32 +441,32 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="44"/>
<location filename="../src/mainwindow-dtk.cpp" line="45"/>
<source>Submit App</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="45"/>
<location filename="../src/mainwindow-dtk.cpp" line="46"/>
<source>Submit App with client(Recommanded)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="46"/>
<location filename="../src/mainwindow-dtk.cpp" line="47"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="47"/>
<location filename="../src/mainwindow-dtk.cpp" line="48"/>
<source>APP Upgrade and Install Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="160"/>
<location filename="../src/mainwindow-dtk.cpp" line="161"/>
<source>Spark Store</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="161"/>
<location filename="../src/mainwindow-dtk.cpp" line="162"/>
<source>Search or enter spk://</source>
<translation type="unfinished"></translation>
</message>
@@ -476,7 +476,7 @@
<message>
<location filename="../src/application.cpp" line="26"/>
<location filename="../src/application.cpp" line="27"/>
<location filename="../src/mainwindow-dtk.cpp" line="21"/>
<location filename="../src/mainwindow-dtk.cpp" line="22"/>
<source>Spark Store</source>
<translation type="unfinished"></translation>
</message>
@@ -584,17 +584,17 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/pages/settingspage.cpp" line="196"/>
<location filename="../src/pages/settingspage.cpp" line="213"/>
<source>Updating, please wait...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/pages/settingspage.cpp" line="218"/>
<location filename="../src/pages/settingspage.cpp" line="235"/>
<source>Spark Store</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/pages/settingspage.cpp" line="218"/>
<location filename="../src/pages/settingspage.cpp" line="235"/>
<source>Temporary cache was cleaned</source>
<translation type="unfinished"></translation>
</message>
+10 -10
View File
@@ -441,32 +441,32 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="44"/>
<location filename="../src/mainwindow-dtk.cpp" line="45"/>
<source>Submit App</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="45"/>
<location filename="../src/mainwindow-dtk.cpp" line="46"/>
<source>Submit App with client(Recommanded)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="46"/>
<location filename="../src/mainwindow-dtk.cpp" line="47"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="47"/>
<location filename="../src/mainwindow-dtk.cpp" line="48"/>
<source>APP Upgrade and Install Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="160"/>
<location filename="../src/mainwindow-dtk.cpp" line="161"/>
<source>Spark Store</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="161"/>
<location filename="../src/mainwindow-dtk.cpp" line="162"/>
<source>Search or enter spk://</source>
<translation type="unfinished"></translation>
</message>
@@ -476,7 +476,7 @@
<message>
<location filename="../src/application.cpp" line="26"/>
<location filename="../src/application.cpp" line="27"/>
<location filename="../src/mainwindow-dtk.cpp" line="21"/>
<location filename="../src/mainwindow-dtk.cpp" line="22"/>
<source>Spark Store</source>
<translation type="unfinished"></translation>
</message>
@@ -584,17 +584,17 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/pages/settingspage.cpp" line="196"/>
<location filename="../src/pages/settingspage.cpp" line="213"/>
<source>Updating, please wait...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/pages/settingspage.cpp" line="218"/>
<location filename="../src/pages/settingspage.cpp" line="235"/>
<source>Spark Store</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/pages/settingspage.cpp" line="218"/>
<location filename="../src/pages/settingspage.cpp" line="235"/>
<source>Temporary cache was cleaned</source>
<translation type="unfinished"></translation>
</message>
+10 -10
View File
@@ -441,32 +441,32 @@
<translation>更新</translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="44"/>
<location filename="../src/mainwindow-dtk.cpp" line="45"/>
<source>Submit App</source>
<translation>投递应用</translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="45"/>
<location filename="../src/mainwindow-dtk.cpp" line="46"/>
<source>Submit App with client(Recommanded)</source>
<translation>使用本地投稿器投递应用(推荐)</translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="46"/>
<location filename="../src/mainwindow-dtk.cpp" line="47"/>
<source>Settings</source>
<translation>设置</translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="47"/>
<location filename="../src/mainwindow-dtk.cpp" line="48"/>
<source>APP Upgrade and Install Settings</source>
<translation>应用更新和安装设置</translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="160"/>
<location filename="../src/mainwindow-dtk.cpp" line="161"/>
<source>Spark Store</source>
<translation>星火应用商店</translation>
</message>
<message>
<location filename="../src/mainwindow-dtk.cpp" line="161"/>
<location filename="../src/mainwindow-dtk.cpp" line="162"/>
<source>Search or enter spk://</source>
<translation>搜索或打开链接</translation>
</message>
@@ -476,7 +476,7 @@
<message>
<location filename="../src/application.cpp" line="26"/>
<location filename="../src/application.cpp" line="27"/>
<location filename="../src/mainwindow-dtk.cpp" line="21"/>
<location filename="../src/mainwindow-dtk.cpp" line="22"/>
<source>Spark Store</source>
<translation>星火应用商店</translation>
</message>
@@ -584,17 +584,17 @@
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;我们并&lt;span style=&quot; font-weight:600;&quot;&gt;不是&lt;/span&gt;官方团队,和你一样,我们也只是众多Linux/deepin系统爱好者和用户之中的一员,我们开发并且运营这个“Spark应用商店”,是为了让社区的朋友们一起分享好用的软件,或者一起参与开发,让大家都用到最新的,最优秀的软件。&lt;/p&gt;&lt;p&gt;我们并没有因此盈利,所有开发和维护人员都不会获得报酬,我们的主要支出大部分依赖于社区对我们的捐助,很感谢大家,这部分捐助让我们并不需要耗费太多精力去担心资金问题。&lt;/p&gt;&lt;p&gt;我们的服务和开发的软件都是免费供给大家使用,交流,学习的,但是在您的使用过程中一定要遵守当地的法律法规,否则出现任何问题和我们无关。&lt;/p&gt;&lt;p&gt;如果商店中任何一部分有侵犯您权益的行为,请告知我们 &amp;lt;jifengshenmo@outlook.com&amp;gt; ,我们会第一时间删除侵权内容。&lt;/p&gt;&lt;p&gt;如果你也想参与我们,不管是参与开发,设计,投递还是投稿作品,我们都欢迎你的加入。&lt;/p&gt;&lt;p&gt;在 Spark IM 联系我们:&lt;a href=&quot;https://chat.shenmo.tech&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://chat.shenmo.tech&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;QQ 群:872690351&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<location filename="../src/pages/settingspage.cpp" line="196"/>
<location filename="../src/pages/settingspage.cpp" line="213"/>
<source>Updating, please wait...</source>
<translation>正在更新,请稍候……</translation>
</message>
<message>
<location filename="../src/pages/settingspage.cpp" line="218"/>
<location filename="../src/pages/settingspage.cpp" line="235"/>
<source>Spark Store</source>
<translation>星火应用商店</translation>
</message>
<message>
<location filename="../src/pages/settingspage.cpp" line="218"/>
<location filename="../src/pages/settingspage.cpp" line="235"/>
<source>Temporary cache was cleaned</source>
<translation>缓存目录已清空</translation>
</message>