Example #1
0
        public async Task RetryAsync(string key)
        {
            await InitAsync();

            var entry = await _connection.Table <UploadQueueEntry>().Where(e => e.Key == key).FirstOrDefaultAsync();

            if (entry != null)
            {
                try
                {
                    var access = new Access(entry.AccessGrant);
                    var multipartUploadService = new MultipartUploadService(access);
                    await multipartUploadService.AbortUploadAsync(entry.BucketName, entry.Key, entry.UploadId);
                }
                catch { }

                entry.BytesCompleted    = 0;
                entry.Failed            = false;
                entry.FailedMessage     = string.Empty;
                entry.CurrentPartNumber = 0;
                entry.UploadId          = string.Empty;
                await _connection.UpdateAsync(entry);

                UploadQueueChangedEvent?.Invoke(QueueChangeType.EntryUpdated, entry);
            }
        }
        public async Task RetryAsync(string key)
        {
            await InitAsync().ConfigureAwait(false);

            var entry = await _connection.Table <UploadQueueEntry>().Where(e => e.Key == key).FirstOrDefaultAsync().ConfigureAwait(false);

            if (entry != null)
            {
                try
                {
                    var access = new Access(entry.AccessGrant);
                    var multipartUploadService = new MultipartUploadService(access);
                    await multipartUploadService.AbortUploadAsync(entry.BucketName, entry.Key, entry.UploadId).ConfigureAwait(false);
                }
                catch
                {
                    //Ignore errors - we restart that upload anyways
                }

                var entryData = await _connection.GetAsync <UploadQueueEntryData>(e => e.UploadQueueEntryId == entry.Id);

                if (entryData != null)
                {
                    entry.BytesCompleted    = 0;
                    entry.Failed            = false;
                    entry.FailedMessage     = string.Empty;
                    entry.CurrentPartNumber = 0;
                    entry.UploadId          = string.Empty;
                    await _connection.RunInTransactionAsync((SQLiteConnection transaction) =>
                    {
                        transaction.Update(entry);
                        transaction.Update(entryData);
                    });
                }

                UploadQueueChangedEvent?.Invoke(QueueChangeType.EntryUpdated, entry);
            }
        }