Skip to content

Commit

Permalink
1 byte files are cropping up, so raise error for those too.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed Oct 4, 2012
1 parent 9fc6f75 commit 5e8bc06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
15 changes: 8 additions & 7 deletions ckanext/archiver/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ class Archiver(CkanCommand):
Usage:
paster archiver update [{package-id}]
- Archive all resources or just those belonging to a specific package
if a package id is provided
paster archiver clean
- Remove all archived resources
"""
paster archiver update [{package-name/id}|{group-name/id}]
- Archive all resources or just those belonging to a specific
package or group, if specified
"""
# TODO:
# paster archiver clean
# - Remove all archived resources

summary = __doc__.split('\n')[0]
usage = __doc__
min_args = 0
Expand Down
10 changes: 5 additions & 5 deletions ckanext/archiver/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ def download(context, resource, url_timeout=30,
raise ChooseNotToDownload("Content-length after streaming reached maximum allowed value of %s" %
max_content_length)

# zero length usually indicates a problem too
if length == 0:
# zero length (or just one byte) indicates a problem too
if length < 2:
if resource_changed:
_update_resource(context, resource, log)
# record fact that resource is zero length
log.warning('Resource found was zero length - not archiving. Resource: %s %r',
resource['id'], url)
raise DownloadError("Content-length after streaming was zero")
log.warning('Resource found was length %i - not archiving. Resource: %s %r',
length, resource['id'], url)
raise DownloadError("Content-length after streaming was %i" % length)

# update the resource metadata in CKAN if the resource has changed
if resource.get('hash') != hash:
Expand Down

0 comments on commit 5e8bc06

Please sign in to comment.