Esempio n. 1
0
        private async Task SyncDeleted(Profile profile)
        {
            var external = External(profile);

            if (profile.HasElapsed(_appConfig.ForcedProfileSyncInterval) && external.ModifiedLaterThan(profile))
            {
                // First wins: Profile was updated while syncing
                await FinishSyncOverridden(profile);

                return;
            }

            // Last wins
            await DeleteInApi(external);
            await FinishSyncDeleted(profile);
        }
Esempio n. 2
0
        private async Task SyncUpdated(Profile profile)
        {
            var external = External(profile);

            if (!external.Exists())
            {
                if (profile.HasElapsed(_appConfig.ForcedProfileSyncInterval))
                {
                    // First wins: Profile was deleted while editing or syncing
                    await Skip(profile);
                }
                else
                {
                    // Last wins: Creating new profile
                    await SyncCreated(profile);
                }

                return;
            }

            var p = profile.WithExternalIdFrom(external);

            if (p.HasElapsed(_appConfig.ForcedProfileSyncInterval) && external.ModifiedLaterThan(p))
            {
                // First wins: Profile was updated while syncing
                await FinishSyncOverridden(p);

                return;
            }

            // Last wins
            p = WithUniqueName(p);
            p = await UpdatedInApi(p);

            await FinishSyncUpdated(p);
        }