Change scope of file processing and adjust di in publish contoller

This commit is contained in:
Hepatica
2024-08-11 02:22:09 +02:00
parent 1f3086c96c
commit f2f8169c61
3 changed files with 16 additions and 10 deletions

View File

@@ -12,18 +12,18 @@ class PublishController
private:
AuthorizationService authorization;
FileProcessingService file_processing;
std::shared_ptr<FileProcessingService> file_processing;//Smart pointer
std::string publish_app_path = "/mnt/c/Users/Danil/SpCloudApp";
//std::string publish_app_path = "/home/danilt2000/SpCloud/";
//std::string publish_app_path = "C:/Temps/";// Todo delete if not needed
public:
PublishController(httplib::Server& svr, AuthorizationService authorization, FileProcessingService file_processing)
PublishController(httplib::Server& svr, AuthorizationService authorization, std::shared_ptr<FileProcessingService> file_processing) : authorization(authorization), file_processing(file_processing)
{
this->authorization = authorization;
/*this->authorization = authorization;
this->file_processing = file_processing;
this->file_processing = file_processing;*/
svr.Post("/publish", [this](const httplib::Request& req, httplib::Response& res)
{
@@ -43,7 +43,7 @@ private:
if (filename.size() >= 4 && filename.substr(filename.size() - 4) == ".rar") {
//if (file_processing.save_file_with_retry(filename, content)) {
if (file_processing.save_file(filename, content)) {
if (file_processing->save_file(filename, content)) {
//Todo uncommit later
//std::string random_string = generate_random_string(20);//Todo think about change
@@ -74,7 +74,7 @@ private:
void dotnet_publish(const std::string& path)
{
std::string dll_file_name = file_processing.find_file_by_suffix(path, "dll");
std::string dll_file_name = file_processing->find_file_by_suffix(path, "dll");
std::string command = R"(dotnet )" + path + "/" + dll_file_name;