serialEach broken in current master
Closed, ResolvedPublic

Description

I ran into another weird issue in current master.

Given the following code:

return runJob<KDAV2::DavCollection::List>(new KDAV2::DavCollectionsFetchJob{ serverUrl },
    [](KJob *job) { return static_cast<KDAV2::DavCollectionsFetchJob *>(job)->collections(); })
    .serialEach([=](const KDAV2::DavCollection &collection) {
        const auto collectionRid = resourceID(collection);
        const auto localId = syncStore().resolveRemoteId(mCollectionType, collectionRid);

        return synchronizeCollection(collection.url(), collectionRid, localId, collection.CTag().toLatin1())
            .then([=] (const KAsync::Error &error) {
                if (error) {
                    SinkWarningCtx(mLogCtx) << "Failed to synchronized folder" << error;
                }
                //Ignore synchronization errors for individual collections, the next one might work.
                return KAsync::null();
            });
    });

The serialEach continuation parameter turns out to be always the same.

I verified that the KDAV2::DavCollection::List is indeed a list with N different values, however continuation is called N times, but with always the same collection parameter.
v0.3.0 works as expected.

I don't understand why the test in asynctest doesn't catch this problem, but it might have something to do with POD types.

cmollekopf triaged this task as Normal priority.
cmollekopf assigned this task to dvratil.
cmollekopf closed this task as Resolved.Dec 4 2020, 7:18 PM

Can't reproduce as of 338138c9d2007e75ebb7f5e97dc5894cb125193d.