Skip to content

Commit

Permalink
Grab the link before finding the CDXLines for permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
leppert committed Mar 17, 2015
1 parent f2113ad commit eb4eeba
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions perma_web/warc_server/pywb_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from pywb.webapp.pywb_init import create_wb_router
from pywb.utils.wbexception import NotFoundException

from perma.models import CDXLine, Asset
from perma.models import CDXLine, Asset, Link

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "perma.settings")

Expand All @@ -40,11 +40,17 @@ def apply_filters(self, wbrequest, matcher):
guid = matcher.group(1)
urlkey = surt(wbrequest.wb_url_str)

# Legacy archives didn't generate CDXLines during
# capture so generate them on demand if not found
try:
# This will filter out links that have user_deleted=True
link = Link.objects.get(guid=guid)
except Link.DoesNotExist:
raise NotFoundException()

try:
line = CDXLine.objects.get(urlkey=urlkey,
asset__link_id=guid)
# Legacy archives didn't generate CDXLines during
# capture so generate them on demand if not found
except CDXLine.DoesNotExist:
asset = Asset.objects.get(link_id=guid)
if asset.warc_capture in [Asset.CAPTURE_STATUS_PENDING, Asset.CAPTURE_STATUS_FAILED]:
Expand Down

0 comments on commit eb4eeba

Please sign in to comment.