upload episode actions to gpodder.net in batches
allows partially successful uploads and resuming; avoids empty uploads
This commit is contained in:
parent
ec3474e149
commit
8d0925ba46
|
@ -73,6 +73,7 @@ from mygpoclient import util as mygpoutil
|
|||
|
||||
EXAMPLES_OPML = 'http://gpodder.org/directory.opml'
|
||||
TOPLIST_OPML = 'http://gpodder.org/toplist.opml'
|
||||
EPISODE_ACTIONS_BATCH_SIZE=100
|
||||
|
||||
# Database model classes
|
||||
class SinceValue(object):
|
||||
|
@ -508,14 +509,20 @@ class MygPoClient(object):
|
|||
|
||||
# Step 2: Upload Episode actions
|
||||
|
||||
# Convert actions to the mygpoclient format for uploading
|
||||
episode_actions = [convert_to_api(a) for a in actions]
|
||||
# Uploads are done in batches; uploading can resume if only parts
|
||||
# be uploaded; avoids empty uploads as well
|
||||
for lower in range(0, len(actions), EPISODE_ACTIONS_BATCH_SIZE):
|
||||
batch = actions[lower:lower+EPISODE_ACTIONS_BATCH_SIZE]
|
||||
|
||||
# Upload the episode actions
|
||||
self._client.upload_episode_actions(episode_actions)
|
||||
# Convert actions to the mygpoclient format for uploading
|
||||
episode_actions = [convert_to_api(a) for a in batch]
|
||||
|
||||
# Upload the episode actions
|
||||
self._client.upload_episode_actions(episode_actions)
|
||||
|
||||
# Actions have been uploaded to the server - remove them
|
||||
self._store.remove(batch)
|
||||
|
||||
# Actions have been uploaded to the server - remove them
|
||||
self._store.remove(actions)
|
||||
logger.debug('Episode actions have been uploaded to the server.')
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in New Issue