diff --git a/Build.Counter b/Build.Counter index d7841fb0..e6330cb6 100644 --- a/Build.Counter +++ b/Build.Counter @@ -1 +1 @@ -2929 +2939 diff --git a/src/QvCoreConfigOperations_Convertion.cpp b/src/QvCoreConfigOperations_Convertion.cpp index 20d72a9d..cb43401e 100644 --- a/src/QvCoreConfigOperations_Convertion.cpp +++ b/src/QvCoreConfigOperations_Convertion.cpp @@ -74,15 +74,27 @@ namespace Qv2ray bool SaveSubscriptionConfig(CONFIGROOT obj, const QString &subscription, const QString &name) { auto str = JsonToString(obj); - QFile *config = new QFile(QV2RAY_SUBSCRIPTION_DIR + subscription + "/" + name + QV2RAY_CONFIG_FILE_EXTENSION); + auto fName = name; + + if (!IsValidFileName(fName + QV2RAY_CONFIG_FILE_EXTENSION)) { + fName = QObject::tr("Invalid filename") + "_" + GenerateRandomString(6) + QV2RAY_CONFIG_FILE_EXTENSION; + } + + QFile *config = new QFile(QV2RAY_SUBSCRIPTION_DIR + subscription + "/" + fName + QV2RAY_CONFIG_FILE_EXTENSION); // If there's already a file. THIS IS EXTREMELY RARE if (config->exists()) { LOG(MODULE_FILE, "Trying to overrwrite an existing subscription config file. THIS IS RARE") } - LOG(MODULE_CONFIG, "Saving a subscription named: " + name) - return StringToFile(&str, config); + LOG(MODULE_CONFIG, "Saving a subscription named: " + fName) + bool result = StringToFile(&str, config); + + if (!result) { + LOG(MODULE_FILE, "Failed to save a connection config from subscription: " + subscription + ", name: " + fName) + } + + return result; } bool RemoveConnection(const QString &alias) diff --git a/src/ui/w_ImportConfig.cpp b/src/ui/w_ImportConfig.cpp index 4bdc6fae..10c3be29 100644 --- a/src/ui/w_ImportConfig.cpp +++ b/src/ui/w_ImportConfig.cpp @@ -237,9 +237,14 @@ void ImportConfigWindow::on_subscriptionButton_clicked() hide(); SubscribeEditor w; w.exec(); - auto _result = w.GetSelectedConfig(); + auto importToComplex = !keepImportedInboundCheckBox->isEnabled(); connections.clear(); - connections[_result.first] = _result.second; + + if (importToComplex) { + auto _result = w.GetSelectedConfig(); + connections[_result.first] = _result.second; + } + accept(); } diff --git a/src/ui/w_MainWindow.cpp b/src/ui/w_MainWindow.cpp index 8335df26..68e33376 100644 --- a/src/ui/w_MainWindow.cpp +++ b/src/ui/w_MainWindow.cpp @@ -948,18 +948,18 @@ void MainWindow::on_pingTestBtn_clicked() if (QvMessageBoxAsk(this, tr("Latency Test"), tr("You are about to run latency test on all servers, do you want to continue?")) == QMessageBox::Yes) { aliases.append(connections.keys()); } - } else if (selection.count() == 1) { - if (IsSelectionConnectable) { - // Current selection is a config - aliases.append(ItemConnectionIdentifier(selection.first())); - } else { - // Current selection is a subscription or... something else strange. - // So we add another check to make sure the selected one is a subscription entry. - if (selection.first()->childCount() > 0) { + } else { + for (auto i = 0; i < selection.count(); i++) { + auto thisItem = selection[i]; + + if (thisItem->childCount() > 0) { + // So we add another check to make sure the selected one is a subscription entry. // Loop to add all sub-connections to the list. - for (auto i = 0; i < selection.first()->childCount(); i++) { - aliases.append(ItemConnectionIdentifier(selection.first()->child(i))); + for (auto j = 0; j < thisItem->childCount(); j++) { + aliases.append(ItemConnectionIdentifier(thisItem->child(j))); } + } else { + aliases.append(ItemConnectionIdentifier(thisItem)); } } } diff --git a/src/ui/w_PreferencesWindow.ui b/src/ui/w_PreferencesWindow.ui index 6292b245..18ff2ab3 100644 --- a/src/ui/w_PreferencesWindow.ui +++ b/src/ui/w_PreferencesWindow.ui @@ -465,7 +465,7 @@ - Assets Directory Path + V2ray Assets Directory diff --git a/src/ui/w_SubscriptionEditor.cpp b/src/ui/w_SubscriptionEditor.cpp index b49d8f4f..c2ff510b 100644 --- a/src/ui/w_SubscriptionEditor.cpp +++ b/src/ui/w_SubscriptionEditor.cpp @@ -135,7 +135,10 @@ void SubscribeEditor::StartUpdateSubscription(const QString &subscriptionName) LOG(MODULE_SUBSCRIPTION, "Processing a subscription with following error: " + errMessage) } else { connectionsList->addItem(_alias); - SaveSubscriptionConfig(config, subscriptionName, _alias); + + if (!SaveSubscriptionConfig(config, subscriptionName, _alias)) { + // Cannot save. + } } }