mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-14 13:05:09 +00:00
perf(hls): rename single decrypted range instead of re-copying
Short-circuit merge() to os.replace() when joining one already-merged file with no init prefix; saves a full track-size copy, falls back to streamed copy across devices.
This commit is contained in:
@@ -740,8 +740,15 @@ class HLS:
|
||||
delete: Delete the file once it's been merged.
|
||||
include_map_data: Whether to include the init map data.
|
||||
"""
|
||||
prepend = include_map_data and map_data and map_data[1]
|
||||
if len(via) == 1 and not prepend and delete:
|
||||
try:
|
||||
os.replace(via[0], to)
|
||||
return
|
||||
except OSError:
|
||||
pass
|
||||
with open(to, "wb") as x:
|
||||
if include_map_data and map_data and map_data[1]:
|
||||
if prepend:
|
||||
x.write(map_data[1])
|
||||
for file in via:
|
||||
with open(file, "rb") as segment:
|
||||
|
||||
Reference in New Issue
Block a user