Explorar o código

Adding a queue and behaviour to process it upon completion of sending a task

logicp %!s(int64=5) %!d(string=hai) anos
pai
achega
fe9210849b
Modificáronse 2 ficheiros con 13 adicións e 2 borrados
  1. 1 1
      .circleci/config.yml
  2. 12 1
      src/client.cpp

+ 1 - 1
.circleci/config.yml

@@ -15,7 +15,7 @@ jobs:
       - run:
           name: notify_production
           command: |
-            curl http://artifact.stronglogicsolutions.com/?artifact=ky_gui
+            curl http://artifact.stronglogicsolutions.com/?artifact=ky_gui&build_id=<< pipeline.number >>
 
 workflows:
  version: 2

+ 12 - 1
src/client.cpp

@@ -441,7 +441,15 @@ void Client::execute() {
  */
 void Client::scheduleTask(std::vector<std::string> task_args, bool file_pending) {
     if (file_pending) {
+      if (m_task.empty()) {
         m_task = task_args;
+      } else {
+        if (!m_task_queue.empty() && m_task_queue.front().args.empty()) {
+          m_task_queue.front().args.assign(task_args.begin(), task_args.end());
+        } else {
+          qDebug() << "Could not identify the queued task for updating";
+        }
+      }
     } else {
         qDebug() << "Requesting a task to be scheduled";
         sendTaskEncoded(TaskType::INSTAGRAM, task_args);
@@ -461,6 +469,9 @@ void Client::sendFiles(QVector<KFileData> files) {
         std::string send_file_operation = createOperation("FileUpload", {});
         sendEncoded(send_file_operation);
     } else {
-        qDebug() << "Still attempting to send a different file";
+      // TODO: place in queue and check queue after we finish scheduling the
+      // task associated with the outgoing files
+      m_task_queue.enqueue(Task{.files = files});
+      qDebug() << "Still attempting to send a different file";
     }
 }