# Log action
log.info(_("Source '%s' has been deleted from '%s'") % (self, self.list))
- def update(self):
+ def update(self, force=False):
"""
Updates this source.
"""
with self.db.transaction():
with self.backend.client() as client:
# Compose some request headers
- headers = self._make_headers()
+ headers = self._make_headers(force=force)
with client.stream("GET", self.url, headers=headers) as response:
# Parse the response headers
# Signal that we have actually fetched new data
return True
- def _make_headers(self):
+ def _make_headers(self, force=False):
"""
Creates some headers we will send with the request.
"""
headers = {}
- # Send If-Modified-Since so that we won't re-import the same list
- if self.last_modified_at:
- headers["If-Modified-Since"] = \
- self.last_modified_at.strftime("%a, %d %b %Y %H:%M:%S GMT")
+ if not force:
+ # Send If-Modified-Since so that we won't re-import the same list
+ if self.last_modified_at:
+ headers["If-Modified-Since"] = \
+ self.last_modified_at.strftime("%a, %d %b %Y %H:%M:%S GMT")
- # If we don't have the timestamp, we will send the ETag
- elif self.etag:
- headers["If-None-Match"] = self.etag
+ # If we don't have the timestamp, we will send the ETag
+ elif self.etag:
+ headers["If-None-Match"] = self.etag
return headers
# update
update = subparsers.add_parser("update", help=_("Updates a list"))
update.add_argument("list", help=_("The name of the list"))
+ update.add_argument("--force", action="store_true", help=_("Force an update"))
update.set_defaults(func=self.__update)
# update-all
list = backend.lists.get_by_slug(args.list)
# Update!
- list.update()
+ list.update(force=args.force)
def __update_all(self, backend, args):
"""