Skip to content

DataFileUploadManager

#include <mrx/spoke-zone/data-files/DataFileUploadManager.hpp>
class mrx::spokezone::DataFileUploadManager

Inherits: QObject

Uploads files selected by configured data-file sets, manually or on the Spoke.Zone logging schedule.

The configuration and DataFilesApi are caller-owned and must outlive this manager. This class uploads files that already exist; it does not record traces or rotate files. Each upload scans the configured file sets, starts the first candidate immediately, and spaces successive file attempts by its interAttemptDelayMs() setting (15 seconds by default). Failed create, upload, and snapshot attempts are retried at the front of the queue up to retryCount() times after the initial attempt; upload retries reuse the record ID created for that file. Once retries are exhausted, the file is skipped for the rest of that batch and retained locally for a later batch. Files larger than the Spoke.Zone 50 MiB data-file limit are rejected before upload. Each upload uses a snapshot; the local file is removed after success only if its contents have not changed since that snapshot. Call setFileSets() while idle to replace the selected directories and patterns. It returns false while a batch or an already-issued request is still active. stop() cancels the queue and future schedule, discarding remote record IDs from the aborted batch; an already-issued request is allowed to finish, but a completed create request will not start a file upload.

ReturnNameDescription
DataFileUploadManager explicit
~DataFileUploadManager override
boolsetFileSetsReplaces the selected directories and patterns unless a batch or issued request is still active.
voidstartStarts automatic uploads according to the active Spoke.Zone schedule; repeated calls are ignored.
voidstopStops automatic scheduling and the current queue without aborting an API request already sent.
booluploadStarts a manual upload batch.
intretryCount const
voidsetRetryCountSets the maximum retries after the initial attempt.
intinterAttemptDelayMs const
voidsetInterAttemptDelayMsSets the delay in milliseconds between attempts.
boolisRunning const
boolisUploading const

explicit
explicit DataFileUploadManager(SpokeZoneConfig& config, DataFilesApi& dataFilesApi, QObject* parent = nullptr)

override
~DataFileUploadManager() override

bool setFileSets(const QList<DataFileSet>& fileSets)

Replaces the selected directories and patterns unless a batch or issued request is still active.


void start()

Starts automatic uploads according to the active Spoke.Zone schedule; repeated calls are ignored.


void stop()

Stops automatic scheduling and the current queue without aborting an API request already sent.


bool upload()

Starts a manual upload batch.

Returns false if a batch/request is active or no files match the configured sets.


const
int retryCount() const

The maximum retries allowed after a file’s initial attempt; defaults to 3.


void setRetryCount(int retryCount)

Sets the maximum retries after the initial attempt.

Negative values are treated as zero.


const
int interAttemptDelayMs() const

The delay in milliseconds between file attempts and retries; defaults to 15000.


void setInterAttemptDelayMs(int delayMs)

Sets the delay in milliseconds between attempts.

Negative values are treated as zero.


const
bool isRunning() const

Whether automatic scheduling is enabled.


const
bool isUploading() const

Whether a batch or an issued request still needs to settle.

ReturnNameDescription
voiduploadStartedEmitted when a manual or scheduled batch begins.
voidfileUploadedEmitted when one file was uploaded successfully.
voidfileUploadFailedEmitted for each failed attempt; after the retry limit, the local file is retained for a later batch.
voidfileRemovalFailedEmitted when cloud upload succeeded but the local file could not be removed.
voiduploadFinishedEmitted when a batch has visited every pending path.
voiduploadCancelledEmitted when stop() cancels the queue; an already-issued request may still emit its file result afterward.
voiduploadScheduledEmitted whenever the next automatic upload time is calculated.
voidscheduleFailedEmitted when an enabled weekly schedule is malformed and cannot be scheduled.

void uploadStarted()

Emitted when a manual or scheduled batch begins.


void fileUploaded(const QString& filePath)

Emitted when one file was uploaded successfully.


void fileUploadFailed(const QString& filePath, const QString& reason)

Emitted for each failed attempt; after the retry limit, the local file is retained for a later batch.


void fileRemovalFailed(const QString& filePath)

Emitted when cloud upload succeeded but the local file could not be removed.


void uploadFinished()

Emitted when a batch has visited every pending path.


void uploadCancelled()

Emitted when stop() cancels the queue; an already-issued request may still emit its file result afterward.


void uploadScheduled(const QDateTime& uploadAtUtc)

Emitted whenever the next automatic upload time is calculated.


void scheduleFailed(const QString& reason)

Emitted when an enabled weekly schedule is malformed and cannot be scheduled.