~xavi-garcia-mena/keeper/owncloud-test

« back to all changes in this revision

Viewing changes to src/service/keeper-task.cpp

  • Committer: Xavi Garcia Mena
  • Date: 2016-11-08 09:03:09 UTC
  • Revision ID: xavi.garcia.mena@canonical.com-20161108090309-bftp84dntt1jycql
storing the manifest file at the end of the last backup task to avoid race conditions

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <QString>
29
29
 
30
30
KeeperTaskPrivate::KeeperTaskPrivate(KeeperTask * keeper_task,
31
 
                  KeeperTask::TaskData const & task_data,
 
31
                  KeeperTask::TaskData & task_data,
32
32
                  QSharedPointer<HelperRegistry> const & helper_registry,
33
33
                  QSharedPointer<StorageFrameworkClient> const & storage)
34
34
    : q_ptr(keeper_task)
132
132
    auto const percent_done = helper_->percent_done();
133
133
    ret.insert(QStringLiteral("percent-done"), double(percent_done));
134
134
 
135
 
    if (task_data_.action == "failed")
 
135
    if (task_data_.action == "failed" || task_data_.action == "cancelled")
136
136
        ret.insert(QStringLiteral("error"), task_data_.error);
137
137
 
138
138
    ret.insert(QStringLiteral("uuid"), uuid);
145
145
 
146
146
void KeeperTaskPrivate::calculate_and_notify_state(Helper::State state)
147
147
{
 
148
    recalculate_task_state();
 
149
    Q_EMIT(q_ptr->task_state_changed(state));
 
150
}
 
151
 
 
152
void KeeperTaskPrivate::recalculate_task_state()
 
153
{
148
154
    state_ = calculate_task_state();
149
 
    Q_EMIT(q_ptr->task_state_changed(state));
150
155
}
151
156
 
152
157
void KeeperTaskPrivate::cancel()
175
180
    return ret;
176
181
}
177
182
 
178
 
KeeperTask::KeeperTask(TaskData const & task_data,
 
183
QString KeeperTaskPrivate::to_string(Helper::State state)
 
184
{
 
185
    if (helper_)
 
186
    {
 
187
        return helper_->to_string(state);
 
188
    }
 
189
    else
 
190
    {
 
191
        qWarning() << "Asking for the string of a state when the helper is not initialized yet";
 
192
        return "bug";
 
193
    }
 
194
}
 
195
 
 
196
KeeperTask::KeeperTask(TaskData & task_data,
179
197
                       QSharedPointer<HelperRegistry> const & helper_registry,
180
198
                       QSharedPointer<StorageFrameworkClient> const & storage,
181
199
                       QObject *parent)
207
225
    return d->state();
208
226
}
209
227
 
 
228
void KeeperTask::recalculate_task_state()
 
229
{
 
230
    Q_D(KeeperTask);
 
231
 
 
232
    return d->recalculate_task_state();
 
233
}
 
234
 
 
235
 
210
236
QVariantMap KeeperTask::get_initial_state(KeeperTask::TaskData const &td)
211
237
{
212
238
    return KeeperTaskPrivate::get_initial_state(td);
218
244
 
219
245
    return d->cancel();
220
246
}
 
247
 
 
248
QString KeeperTask::to_string(Helper::State state)
 
249
{
 
250
    Q_D(KeeperTask);
 
251
 
 
252
    return d->to_string(state);
 
253
}