Skip to content

Commit 9796e74

Browse files
committedJan 13, 2025·
Fix
1 parent a641cfd commit 9796e74

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎lecture/lecture/wsgi.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
local_share_dir = Path("/home/hacker/.local/share/")
2121
local_share_dir.mkdir(parents=True, exist_ok=True)
2222
os.chown(local_share_dir, 1000, 1000)
23-
timeline_path = local_share_dir / "lectures" / f"{youtube_id}.jsonl"
23+
timeline_path = local_share_dir / "lectures" / f"{youtube_id}.zlib"
2424
timeline_path.parent.mkdir(parents=True, exist_ok=True)
2525
timeline_file = timeline_path.open("ab")
2626
timeline_compressor = zlib.compressobj()
@@ -54,7 +54,8 @@ def update_telemetry(youtube_id):
5454
event["youtube_id"] = youtube_id
5555
event["timestamp"] = time.time()
5656
timeline.append(event)
57-
timeline_file.write(timeline_compressor.compress(json.dumps(event).encode() + b"\n"))
57+
timeline_file.write(timeline_compressor.compress(json.dumps(event).encode() + b"\n") +
58+
timeline_compressor.flush(zlib.Z_SYNC_FLUSH))
5859
timeline_file.flush()
5960

6061
result = {}

0 commit comments

Comments
 (0)
Please sign in to comment.