Ver código fonte

fix monitor configure update

xuqiang 4 meses atrás
pai
commit
8839e79caf
2 arquivos alterados com 7 adições e 2 exclusões
  1. 5 1
      src/httpserver.cpp
  2. 2 1
      src/mainwindow.cpp

+ 5 - 1
src/httpserver.cpp

@@ -235,16 +235,18 @@ void HttpServer::run_hhttp_sever()
                                 filename = QString("%1/%2").arg(savePath, "monitor.xml");
                             } else if(type == "netparse") {
                                 savePath = QString("%1/%2").arg(currentPath, "storage/upload/netparse");
+                                filename = QString("%1/%2").arg(savePath, QString::fromStdString(item.filename));
                             } else if(type == "formula") {
                                 savePath = QString("%1/%2").arg(currentPath, "storage/upload/formula");
+                                filename = QString("%1/%2").arg(savePath, QString::fromStdString(item.filename));
                             } else if(type == "pluginadd" || type == "pluginupgrade") {
                                 savePath = QString("%1/%2").arg(currentPath, "storage/upload/plugins");
+                                filename = QString("%1/%2").arg(savePath, QString::fromStdString(item.filename));
                             } else {
                                 res.status = httplib::StatusCode::BadRequest_400;
                                 res.set_content(R"({"message": "Invalid file type"})", "application/json");
                                 return;
                             }
-                            filename = QString("%1/%2").arg(savePath, QString::fromStdString(item.filename));
 
                             QDir dir(savePath);
                             if(!dir.exists()) {
@@ -259,6 +261,8 @@ void HttpServer::run_hhttp_sever()
 
                             ofs.write(item.content.data(), item.content.size());
                             ofs.close();
+
+                            LOG_INFO("upload filename: {}", filename.toStdString());
                             
                             if(type == "monitor") {
                                 LOG_INFO("monitor configure file successfully update");

+ 2 - 1
src/mainwindow.cpp

@@ -223,7 +223,8 @@ void MainWindow::onConfigureUpdate(const QString &filename)
     canvasCount = projectMgr.canvasCount();
     projectMgr.closeProject();
 
-    QString srcFileName = QString("%1/%2").arg(QDir::currentPath(), "update/monitor.xml");
+    // QString srcFileName = QString("%1/%2").arg(QDir::currentPath(), "update/monitor.xml");
+    QString srcFileName = filename;
     QString dstFileName = QString("%1/%2").arg(QDir::currentPath(), "conf/monitor.xml");
     bool ret;
     // bool result = projectMgr.openProject(fileName);