Skip to content

Commit 2547ea1

Browse files
committed
Experiment
1 parent 533de5c commit 2547ea1

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

pywb/warcserver/access_checker.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,29 +174,23 @@ def check_embargo(self, url, ts):
174174
return access if actual > dt else None
175175

176176
def check_date_access(
177-
self, ts, access, default_access, rule
177+
self, ts, access, rule
178178
):
179179
"""Return access based on date fields in access rule
180180
181-
If a date-based rule exists and condition is not met, return default rule
182181
If no date-based rule exists, return access
183182
"""
184-
if not rule:
185-
return access
186-
187183
dt = timestamp_to_datetime(ts, tz_aware=True)
188184

189185
before_ts = rule.get('before')
190186
if before_ts:
191187
before = timestamp_to_datetime(before_ts, tz_aware=True)
192-
return access if dt < before else default_access
188+
return access if dt < before else None
193189

194190
after_ts = rule.get('after')
195191
if after_ts:
196192
after = timestamp_to_datetime(after_ts, tz_aware=True)
197-
return access if dt > after else default_access
198-
199-
return access
193+
return access if dt > after else None
200194

201195
def create_access_aggregator(self, source_files):
202196
"""Creates a new AccessRulesAggregator using the supplied list
@@ -350,9 +344,12 @@ def wrap_iter(self, cdx_iter, acl_user):
350344

351345
access = rule.get('access', 'exclude')
352346

353-
access = self.check_date_access(
354-
timestamp, access, default_access, rule
355-
)
347+
if rule:
348+
date_access = self.check_date_access(
349+
timestamp, access, rule
350+
)
351+
if date_access:
352+
access = date_access
356353

357354
if access != 'allow_ignore_embargo' and access != 'exclude':
358355
embargo_access = self.check_embargo(url, timestamp)

0 commit comments

Comments
 (0)