From df586e9bb7a303329547b9f9d9fdb40061ddfe09 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Mon, 8 Sep 2025 21:41:11 -0500 Subject: [PATCH] browsercache_simple: Code for 0 length stream in cache file, only seen in Mac --- .../browsercache/browsercache_simple.py | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/fanficfare/browsercache/browsercache_simple.py b/fanficfare/browsercache/browsercache_simple.py index d54f7c42..3e4a35b8 100644 --- a/fanficfare/browsercache/browsercache_simple.py +++ b/fanficfare/browsercache/browsercache_simple.py @@ -38,8 +38,8 @@ class SimpleCacheException(BrowserCacheException): SIMPLE_EOF = struct.Struct('>>Stream size == 0") + entry_file.seek(0, os.SEEK_SET) + _read_entry_file_key(entry_file) + stream_size = start_eof_header - entry_file.tell() + else: + seek_back = stream_size + SIMPLE_EOF_SIZE + if flags & FLAG_HAS_SHA256: + seek_back += 32 + entry_file.seek(-seek_back, os.SEEK_CUR) return stream_size @@ -199,8 +210,8 @@ def _get_data_from_entry_file(path): def _read_data_from_entry(entry_file): """ Read the contents portion (stream 1 data) from the instance's cache entry. Return a byte string """ entry_file.seek(0, os.SEEK_END) - _skip_to_start_of_stream(entry_file) - stream_size = _skip_to_start_of_stream(entry_file) + _skip_to_start_of_stream(entry_file) # skip to start of LAST stream + stream_size = _skip_to_start_of_stream(entry_file) # to start of FIRST stream ret = entry_file.read(stream_size) return ret @@ -233,8 +244,9 @@ def _read_meta_headers(entry_file): # uint32 info_size, uint32 flags, uint32 extra_flags, uint64 request_time, uint64 response_time, uint64 orig_response_time, uint32 header_size PRE_META_HEADER = struct.Struct('