Don't error when encountering a temp-type segment

These can happen if a downloader or backfiller dies suddenly.
We treat it similarly to partial but lacking any hash.

At some point in the future we should probably have something
to find any temp segments, hash them and rename them to partials.
pull/52/head
Mike Lang 6 years ago committed by Mike Lang
parent f8d10dacdf
commit cca4d52b7d

@ -55,16 +55,17 @@ def parse_segment_path(path):
if len(parts) != 4: if len(parts) != 4:
raise ValueError("Not enough dashes in filename") raise ValueError("Not enough dashes in filename")
time, duration, type, hash = parts time, duration, type, hash = parts
if type not in ('full', 'partial'): if type not in ('full', 'partial', 'temp'):
raise ValueError("Unknown type {!r}".format(type)) raise ValueError("Unknown type {!r}".format(type))
hash = None if type == 'temp' else unpadded_b64_decode(hash)
return SegmentInfo( return SegmentInfo(
path = path, path = path,
stream = stream, stream = stream,
variant = variant, variant = variant,
start = datetime.datetime.strptime("{}:{}".format(hour, time), "%Y-%m-%dT%H:%M:%S.%f"), start = datetime.datetime.strptime("{}:{}".format(hour, time), "%Y-%m-%dT%H:%M:%S.%f"),
duration = datetime.timedelta(seconds=float(duration)), duration = datetime.timedelta(seconds=float(duration)),
is_partial = type == "partial", is_partial = type != "full",
hash = unpadded_b64_decode(hash), hash = hash,
) )
except ValueError as e: except ValueError as e:
# wrap error but preserve original traceback # wrap error but preserve original traceback

Loading…
Cancel
Save