vomebook commited on
Commit ·
fbb2c8f
1
Parent(s): 8a50c4c
Preserve repeated extensions and recover legacy reader links
Browse filesFiles changed (8)
50 unmodified lines5152535455565744 unmodified lines102103104105106107425 unmodified lines5335345355365375385395405415425435445455464 unmodified lines5515525535545555569 unmodified lines56656756856957057148 unmodified lines62062162262362462562615 unmodified lines6426436446456466472011 unmodified lines265926602661266226632664266550 unmodified linesREADER_ASSET_MODES,add_reader_assets, build_browser_file_name, build_reader_asset_key,build_record_link, build_record_path_url, build_record_relative_path,build_txt_relative_path, enrich_browser_entry, enrich_reader_record,reader_asset_url, reader_extension_for_asset, reader_resolved_record,)from backend.upstream_http import (44 unmodified linesrepo_reader_record_indices = {}reader_record_key_indices = {}reader_source_id_indices = {}_reader_indexes_ready = False_reader_indexes_lock = threading.Lock()_reader_index_build = None425 unmodified linesdef _advance_reader_indexes(limit=READER_INDEX_BATCH_RECORDS, budget=READER_INDEX_BATCH_SECONDS):global reader_record_indices, repo_reader_record_indicesglobal reader_record_key_indices, reader_source_id_indices, _reader_indexes_readyglobal _reader_index_buildwith _reader_indexes_lock:if _reader_indexes_ready:return Trueif _reader_index_build is None or _reader_index_build["generation"] != _data_generation:_reader_index_build = {"generation": _data_generation, "records": records, "next": 0,"indices": [], "repos": {}, "keys": {}, "ids": {}}build = _reader_index_builddeadline = time.perf_counter() + budgetend = min(len(build["records"]), build["next"] + limit)4 unmodified linesbuild["keys"][build_reader_asset_key(rec)] = idxsource_id = reader_short_id(rec.get("Link") or build_record_link(rec))build["ids"].setdefault(source_id, []).append(idx)if rec.get("_ext_lower", "") in READER_EXTENSIONS:build["indices"].append(idx)build["repos"].setdefault(repo, []).append(idx)9 unmodified linesrepo_reader_record_indices = {key: array('I', indices) for key, indices in build["repos"].items()}reader_record_key_indices = build["keys"]reader_source_id_indices = build["ids"]_reader_indexes_ready = True_reader_index_build = Nonereturn True48 unmodified linesdef build_indexes(build_words=True, build_reader=True):global _reader_index_buildglobal reader_source_id_indices, _search_generationglobal _data_generation, word_index, word_index_buffer, folder_index, extension_counts, repo_counts, repo_list, extension_list, repo_extension_counts, repo_records_map, sorted_by_name, sorted_by_size, repo_sorted_by_name, repo_sorted_by_size, txt_record_indices, repo_txt_record_indices, reader_record_indices, repo_reader_record_indices, reader_record_key_indices, _reader_indexes_ready_data_generation += 1_search_generation = None15 unmodified linesrepo_reader_record_indices = {}reader_record_key_indices = {}reader_source_id_indices = {}_reader_indexes_ready = False_reader_index_build = Nonefor idx, rec in enumerate(records):2011 unmodified lines# originals (such as PS) become cached as the Reader's document source.assets = await get_reader_assets(wait=not bool(reader_assets_cache.get("f")))matches = []for index in reader_source_id_indices.get(id, []):record = records[index]matches.append(reader_resolved_record(record, assets.get("f", {}).get(build_reader_asset_key(record), {})))if len({canonical_reader_source_url(match["download"]) for match in matches}) > 1:50 unmodified lines5152535455565744 unmodified lines102103104105106107108425 unmodified lines5345355365375385395405415425435445455465474 unmodified lines5525535545555565575585595605615625635645655665675685699 unmodified lines57958058158258358458548 unmodified lines63463563663763863964015 unmodified lines6566576586596606616622011 unmodified lines26742675267626772678267926802681268250 unmodified linesREADER_ASSET_MODES,add_reader_assets, build_browser_file_name, build_reader_asset_key,build_record_link, build_record_path_url, build_record_relative_path,build_txt_relative_path, dataset_file_url, enrich_browser_entry, enrich_reader_record,reader_asset_url, reader_extension_for_asset, reader_resolved_record,)from backend.upstream_http import (44 unmodified linesrepo_reader_record_indices = {}reader_record_key_indices = {}reader_source_id_indices = {}reader_legacy_source_id_indices = {}_reader_indexes_ready = False_reader_indexes_lock = threading.Lock()_reader_index_build = None425 unmodified linesdef _advance_reader_indexes(limit=READER_INDEX_BATCH_RECORDS, budget=READER_INDEX_BATCH_SECONDS):global reader_record_indices, repo_reader_record_indicesglobal reader_record_key_indices, reader_source_id_indices, reader_legacy_source_id_indices, _reader_indexes_readyglobal _reader_index_buildwith _reader_indexes_lock:if _reader_indexes_ready:return Trueif _reader_index_build is None or _reader_index_build["generation"] != _data_generation:_reader_index_build = {"generation": _data_generation, "records": records, "next": 0,"indices": [], "repos": {}, "keys": {}, "ids": {}, "legacy_ids": {}}build = _reader_index_builddeadline = time.perf_counter() + budgetend = min(len(build["records"]), build["next"] + limit)4 unmodified linesbuild["keys"][build_reader_asset_key(rec)] = idxsource_id = reader_short_id(rec.get("Link") or build_record_link(rec))build["ids"].setdefault(source_id, []).append(idx)# Older sidebar code mistakenly omitted the final extension when# the stem already ended in it. Keep a bounded compatibility index# only for a uniquely matching same-path record; never scan on a# request or infer an unknown URL from its short hash.name, ext, folders = rec.get("File", ""), rec.get("Extension", ""), rec.get("Folder", [])if (isinstance(repo, str) and repo.startswith("VoiceOfML/") and isinstance(name, str)and isinstance(ext, str) and ext and name.lower().endswith("." + ext.lower())and isinstance(folders, list) and all(isinstance(part, str) for part in folders)):legacy_path = "/".join([*folders, name])legacy_url = dataset_file_url(repo, legacy_path)if legacy_url != (rec.get("Link") or build_record_link(rec)):build["legacy_ids"].setdefault(reader_short_id(legacy_url), []).append(idx)if rec.get("_ext_lower", "") in READER_EXTENSIONS:build["indices"].append(idx)build["repos"].setdefault(repo, []).append(idx)9 unmodified linesrepo_reader_record_indices = {key: array('I', indices) for key, indices in build["repos"].items()}reader_record_key_indices = build["keys"]reader_source_id_indices = build["ids"]reader_legacy_source_id_indices = build["legacy_ids"]_reader_indexes_ready = True_reader_index_build = Nonereturn True48 unmodified linesdef build_indexes(build_words=True, build_reader=True):global _reader_index_buildglobal reader_source_id_indices, reader_legacy_source_id_indices, _search_generationglobal _data_generation, word_index, word_index_buffer, folder_index, extension_counts, repo_counts, repo_list, extension_list, repo_extension_counts, repo_records_map, sorted_by_name, sorted_by_size, repo_sorted_by_name, repo_sorted_by_size, txt_record_indices, repo_txt_record_indices, reader_record_indices, repo_reader_record_indices, reader_record_key_indices, _reader_indexes_ready_data_generation += 1_search_generation = None15 unmodified linesrepo_reader_record_indices = {}reader_record_key_indices = {}reader_source_id_indices = {}reader_legacy_source_id_indices = {}_reader_indexes_ready = False_reader_index_build = Nonefor idx, rec in enumerate(records):2011 unmodified lines# originals (such as PS) become cached as the Reader's document source.assets = await get_reader_assets(wait=not bool(reader_assets_cache.get("f")))matches = []# Exact source IDs always take precedence. A legacy sidebar alias is used# only when no exact source exists and the alias names one canonical file.for index in reader_source_id_indices.get(id, []) or reader_legacy_source_id_indices.get(id, []):record = records[index]matches.append(reader_resolved_record(record, assets.get("f", {}).get(build_reader_asset_key(record), {})))if len({canonical_reader_source_url(match["download"]) for match in matches}) > 1:
44 unmodified lines4546474849505144 unmodified linesdef build_browser_file_name(file_item: dict) -> str:name = str(file_item.get("name", "") or "file")ext = str(file_item.get("ext", "") or "")if not ext or name.lower().endswith(f".{ext.lower()}"):return namereturn f"{name}.{ext}"44 unmodified lines45464748495051525344 unmodified linesdef build_browser_file_name(file_item: dict) -> str:name = str(file_item.get("name", "") or "file")ext = str(file_item.get("ext", "") or "")# Browser metadata stores the source record's stem and last extension in# separate fields; a repeated suffix in the stem is still significant.if not ext:return namereturn f"{name}.{ext}"
2422 unmodified lines24232424242524262427242824292422 unmodified linesconst name = file && file.name ? String(file.name) : "file";const ext = file && file.ext ? String(file.ext) : "";if (!ext) return name;if (name.toLowerCase().endsWith(`.${ext.toLowerCase()}`)) return name;return `${name}.${ext}`;}2422 unmodified lines242324242425242624272428242924302422 unmodified linesconst name = file && file.name ? String(file.name) : "file";const ext = file && file.ext ? String(file.ext) : "";if (!ext) return name;// Directory entries carry the filename stem and final extension separately;// the stem can itself end in the same extension.return `${name}.${ext}`;}
43 unmodified lines444546474849505152535443 unmodified linesresult = app.decode_folder_browser_data({"Repo/A": {"": {"folders": [{"name": "legacy"}], "files": []}}})["Repo/A"][""]self.assertEqual(result["folders"], [])def test_record_and_browser_names_do_not_duplicate_extensions(self):self.assertEqual(app.build_browser_file_name({"name": "book.PDF", "ext": "pdf"}), "book.PDF")self.assertEqual(app.build_browser_file_name({"name": "book", "ext": "pdf"}), "book.pdf")self.assertEqual(app.build_txt_relative_path({"File": "book", "Extension": "pdf", "Folder": ["a"]}), "a/book.txt")if __name__ == "__main__":unittest.main()43 unmodified lines44454647484950515253545556575859606162636443 unmodified linesresult = app.decode_folder_browser_data({"Repo/A": {"": {"folders": [{"name": "legacy"}], "files": []}}})["Repo/A"][""]self.assertEqual(result["folders"], [])def test_record_and_browser_names_preserve_repeated_extensions(self):self.assertEqual(app.build_browser_file_name({"name": "book.PDF", "ext": "pdf"}), "book.PDF.pdf")self.assertEqual(app.build_browser_file_name({"name": "book", "ext": "pdf"}), "book.pdf")self.assertEqual(app.build_browser_file_name({"name": "untitled", "ext": ""}), "untitled")self.assertEqual(app.build_txt_relative_path({"File": "book", "Extension": "pdf", "Folder": ["a"]}), "a/book.txt")def test_browser_compact_entries_generate_exact_links_for_all_name_shapes(self):from urllib.parse import unquote, urlsplitentry=app.decode_folder_browser_data({'VoiceOfML/Test': {'目录': {'d': [], 'f': [{'n':'poster.jpg','e':'jpg','s':1}, {'n':'cover','e':'jpg','s':2},{'n':'letter.TXT','e':'txt','s':3}, {'n':'README','e':'','s':4}]}}})['VoiceOfML/Test']['目录']result=app.enrich_browser_entry('VoiceOfML/Test','目录',entry)self.assertEqual([unquote(urlsplit(item['link']).path).split('/')[-1] for item in result['files']],['poster.jpg.jpg','cover.jpg','letter.TXT.txt','README'])if __name__ == "__main__":unittest.main()
23 unmodified lines242526272829345 unmodified lines375376377378379380156 unmodified lines5375385395405415425435 unmodified lines54955055155255355455555623 unmodified linesdef setUp(self):self.saved = {name: copy.deepcopy(getattr(app, name)) for name in ("records", "repo_counts", "repo_list", "repo_records_map", "extension_counts", "extension_list", "repo_extension_counts", "folder_index", "folder_tree_data", "folder_browser_data", "api_response_cache", "initial_payload_global", "initial_payload_by_repo", "reader_record_indices", "repo_reader_record_indices", "reader_record_key_indices", "reader_assets_cache", "reader_assets_cache_at", "reader_assets_revision", "reader_join_cache_key", "reader_join_cache", "READER_ASSET_ROUTING_CONTRACT_VERSION")}self.saved["reader_source_id_indices"] = copy.deepcopy(app.reader_source_id_indices)app.records = [{"Repo": "VoiceOfML/Test", "File": "readme", "Extension": "txt", "Folder": ["docs"], "Size": 10, "HasTxt": True}]app.reader_assets_cache = {"v": 1, "f": {}}app.reader_assets_cache_at = time.monotonic()345 unmodified linesresponse = self.client.get("/api/reader-resolve", params={"id": "0" * 13})self.assertEqual(response.status_code, 409)def test_reader_resolve_uses_native_asset_file_extension(self):for extension in ("epub", "mobi", "azw", "azw3", "fb2"):with self.subTest(extension=extension):156 unmodified linesself.assertEqual(data["extension"], "epub")self.assertEqual(data["download"], original_link)def test_reader_resolve_upgrades_original_pdf_id_to_page_stream(self):original_link = "https://huggingface.co/datasets/VoiceOfML/Test/resolve/main/books/scan.pdf"app.records = [{"Repo": "VoiceOfML/Test", "File": "scan", "Extension": "pdf", "Folder": ["books"], "Size": 10, "HasTxt": False, "Link": original_link},5 unmodified linesresponse = self.client.get("/api/reader-resolve", params={"id": app.reader_short_id(original_link)})self.assertEqual(response.status_code, 200)data = response.json()self.assertEqual(data["extension"], "pdf-pages")self.assertTrue(data["url"].endswith(asset_path))self.assertEqual(data["download"], original_link)def test_reader_resolve_deduplicates_metadata_for_the_same_converted_file(self):23 unmodified lines24252627282930345 unmodified lines376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427156 unmodified lines5845855865875885895905 unmodified lines59659759859960060160260360460523 unmodified linesdef setUp(self):self.saved = {name: copy.deepcopy(getattr(app, name)) for name in ("records", "repo_counts", "repo_list", "repo_records_map", "extension_counts", "extension_list", "repo_extension_counts", "folder_index", "folder_tree_data", "folder_browser_data", "api_response_cache", "initial_payload_global", "initial_payload_by_repo", "reader_record_indices", "repo_reader_record_indices", "reader_record_key_indices", "reader_assets_cache", "reader_assets_cache_at", "reader_assets_revision", "reader_join_cache_key", "reader_join_cache", "READER_ASSET_ROUTING_CONTRACT_VERSION")}self.saved["reader_source_id_indices"] = copy.deepcopy(app.reader_source_id_indices)self.saved["reader_legacy_source_id_indices"] = copy.deepcopy(app.reader_legacy_source_id_indices)app.records = [{"Repo": "VoiceOfML/Test", "File": "readme", "Extension": "txt", "Folder": ["docs"], "Size": 10, "HasTxt": True}]app.reader_assets_cache = {"v": 1, "f": {}}app.reader_assets_cache_at = time.monotonic()345 unmodified linesresponse = self.client.get("/api/reader-resolve", params={"id": "0" * 13})self.assertEqual(response.status_code, 409)def test_legacy_double_extension_id_is_compatible_without_stealing_exact_sources(self):duplicate = {"Repo":"VoiceOfML/Test", "File":"photo.jpg", "Extension":"jpg", "Folder":["docs"]}exact = {"Repo":"VoiceOfML/Test", "File":"photo", "Extension":"jpg", "Folder":["docs"]}legacy = app.reader_short_id(app.build_record_link(exact))current = app.reader_short_id(app.build_record_link(duplicate))assets = mock.AsyncMock(return_value={"v":1,"f":{}})app.records=[duplicate];app.build_indexes(build_words=False)with mock.patch.object(app,"get_reader_assets",assets):resolved=self.client.get('/api/reader-resolve',params={'id':legacy})self.assertEqual(resolved.status_code,200)self.assertTrue(resolved.json()['download'].endswith('/docs/photo.jpg.jpg'))self.assertEqual(self.client.get('/api/reader-resolve',params={'id':current}).status_code,200)# An actual source whose canonical ID matches the historical typo# must win; never silently redirect a valid ID to another file.app.records=[duplicate,exact];app.build_indexes(build_words=False)resolved=self.client.get('/api/reader-resolve',params={'id':legacy})self.assertEqual(resolved.status_code,200)self.assertTrue(resolved.json()['download'].endswith('/docs/photo.jpg'))def test_reported_image_legacy_reader_id_resolves_to_indexed_original_and_existing_asset(self):folder=['马列之声ebook小组第二批成果集成赞助部分','jiang','中国社会主义时代的教育革命 研究资料集成pdf(近800种)','中国社会主义时代教育与卫生革命招贴画']record={'Repo':'VoiceOfML/VOMEBOOK','File':'www.maopost.com_postl_0566_001M.jpg','Extension':'jpg','Folder':folder,'Size':92247,'HasTxt':False}app.records=[record];app.build_indexes(build_words=False)asset={'s':2,'m':'i','b':'vomebook/reader-assets-v2','p':'pages/image/jpg/ff23b0fb45590884ab0968d4b4c40c066d57d29c27a76401f0d658e1a213cff6/document.webp'}sidecar={'v':1,'f':{app.build_reader_asset_key(record):asset}}with mock.patch.object(app,'get_reader_assets',mock.AsyncMock(return_value=sidecar)):response=self.client.get('/api/reader-resolve',params={'id':'2w2m8oowhjtl9'})self.assertEqual(response.status_code,200)self.assertTrue(response.json()['download'].endswith('/www.maopost.com_postl_0566_001M.jpg.jpg'))self.assertEqual(response.json()['extension'],'webp')self.assertIn(asset['p'],response.json()['url'])def test_legacy_double_extension_alias_collision_fails_closed(self):app.records=[{"Repo":"VoiceOfML/Test", "File":name, "Extension":"jpg", "Folder":[]}for name in ('one.jpg','two.jpg')]real = app.reader_short_idwith mock.patch.object(app,'reader_short_id',side_effect=lambda url:'0'*13 if url.endswith(('/one.jpg','/two.jpg')) else real(url)):app.build_indexes(build_words=False)with mock.patch.object(app,'get_reader_assets',mock.AsyncMock(return_value={'v':1,'f':{}})):self.assertEqual(self.client.get('/api/reader-resolve',params={'id':'0'*13}).status_code,409)def test_reader_resolve_uses_native_asset_file_extension(self):for extension in ("epub", "mobi", "azw", "azw3", "fb2"):with self.subTest(extension=extension):156 unmodified linesself.assertEqual(data["extension"], "epub")self.assertEqual(data["download"], original_link)def test_reader_resolve_keeps_original_pdf_when_only_legacy_page_stream_exists(self):original_link = "https://huggingface.co/datasets/VoiceOfML/Test/resolve/main/books/scan.pdf"app.records = [{"Repo": "VoiceOfML/Test", "File": "scan", "Extension": "pdf", "Folder": ["books"], "Size": 10, "HasTxt": False, "Link": original_link},5 unmodified linesresponse = self.client.get("/api/reader-resolve", params={"id": app.reader_short_id(original_link)})self.assertEqual(response.status_code, 200)data = response.json()# Historical page manifests have been retired from Reader routing;# the validated original remains the only reading source here.self.assertEqual(data["extension"], "pdf")self.assertEqual(data["url"], original_link)self.assertEqual(data["download"], original_link)def test_reader_resolve_deduplicates_metadata_for_the_same_converted_file(self):
19 unmodified lines2021222324258 unmodified lines3435363738394048 unmodified lines89909192939419 unmodified linesapp.repo_reader_record_indices,app.reader_record_key_indices,app.reader_source_id_indices,)self.saved_task = getattr(app.app.state, "reader_index_build_task", None)app.records = [{8 unmodified linesapp._reader_indexes_ready = self.saved_readyapp._reader_index_build = self.saved_build(app.reader_record_indices, app.repo_reader_record_indices,app.reader_record_key_indices, app.reader_source_id_indices) = self.saved_indicesapp.app.state.reader_index_build_task = self.saved_taskasync def test_concurrent_reader_requests_share_one_build(self):48 unmodified linesawait app.ensure_reader_indexes_async()self.assertEqual(list(app.reader_record_key_indices), [app.build_reader_asset_key(app.records[0])])if __name__ == "__main__":unittest.main()19 unmodified lines202122232425268 unmodified lines353637383940414248 unmodified lines91929394959697989910010110210310410510610710819 unmodified linesapp.repo_reader_record_indices,app.reader_record_key_indices,app.reader_source_id_indices,app.reader_legacy_source_id_indices,)self.saved_task = getattr(app.app.state, "reader_index_build_task", None)app.records = [{8 unmodified linesapp._reader_indexes_ready = self.saved_readyapp._reader_index_build = self.saved_build(app.reader_record_indices, app.repo_reader_record_indices,app.reader_record_key_indices, app.reader_source_id_indices,app.reader_legacy_source_id_indices) = self.saved_indicesapp.app.state.reader_index_build_task = self.saved_taskasync def test_concurrent_reader_requests_share_one_build(self):48 unmodified linesawait app.ensure_reader_indexes_async()self.assertEqual(list(app.reader_record_key_indices), [app.build_reader_asset_key(app.records[0])])async def test_legacy_aliases_are_published_only_with_the_complete_index(self):app.records = [{'Repo':'VoiceOfML/Test','File':'photo.jpg','Extension':'jpg','Folder':[]},{'Repo':'VoiceOfML/Test','File':'other','Extension':'txt','Folder':[]}]app.build_indexes(build_words=False, build_reader=False)self.assertFalse(app._advance_reader_indexes(limit=1,budget=float('inf')))self.assertEqual(app.reader_legacy_source_id_indices,{})self.assertTrue(app._advance_reader_indexes(limit=10,budget=float('inf')))legacy=app.reader_short_id('https://huggingface.co/datasets/VoiceOfML/Test/resolve/main/photo.jpg')self.assertEqual(app.reader_legacy_source_id_indices[legacy],[0])app.records=[];app.build_indexes(build_words=False,build_reader=False)self.assertEqual(app.reader_legacy_source_id_indices,{})if __name__ == "__main__":unittest.main()
92 unmodified lines93949596979892 unmodified linesself.assertIsNotNone(result['expected'])self.assertEqual(result['captured'], result['expected'])def test_explicit_close_ignores_late_panel_state_before_history_pop(self):self.page.evaluate('navigateToReader("/static/reader.html?ext=txt")')self.page.frame_locator('.reader-overlay').locator('body').wait_for()92 unmodified lines9394959697989910010110210310410510610710810911011111211311411592 unmodified linesself.assertIsNotNone(result['expected'])self.assertEqual(result['captured'], result['expected'])def test_directory_preserves_repeated_filename_extension_for_read_and_download(self):result = self.page.evaluate('''() => {const repo='Test', folder='目录', files=[{name:'poster.jpg',ext:'jpg',size:1}, {name:'normal',ext:'jpg',size:1},{name:'book.PDF',ext:'pdf',size:1}, {name:'README',ext:'',size:1}];const list=document.createElement('div');list.className='browser-list';DOM.sidebarContent.append(list);renderBrowserListItems(list,{folders:[],files},repo,folder);return [...list.querySelectorAll('.browser-item')].map(row=>({filename:row.dataset.filename,link:decodeURIComponent(new URL(row.dataset.link).pathname),reader:row.dataset.readUrl ? new URL(row.dataset.readUrl,location.href).searchParams.get('id') : null}));}''')self.assertEqual([row['filename'] for row in result],['poster.jpg.jpg','normal.jpg','book.PDF.pdf','README'])for row in result:self.assertTrue(row['link'].endswith('/目录/'+row['filename']))self.assertTrue(result[0]['reader'])def test_explicit_close_ignores_late_panel_state_before_history_pop(self):self.page.evaluate('navigateToReader("/static/reader.html?ext=txt")')self.page.frame_locator('.reader-overlay').locator('body').wait_for()
185 unmodified lines186187188189190191185 unmodified linesself.assertEqual([file["name"] for file in result["files"]], ["direct"])self.assertEqual(result["folders"], [{"name": "child", "path": "docs/child", "count": 1}])def test_search_timing_logs_first_and_slow_requests_without_query_content(self):with mock.patch.object(app, "_search_logged_generation", None), mock.patch("builtins.print") as log:app.search("private-query")185 unmodified lines186187188189190191192193194195196197198199200201202203204205185 unmodified linesself.assertEqual([file["name"] for file in result["files"]], ["direct"])self.assertEqual(result["folders"], [{"name": "child", "path": "docs/child", "count": 1}])def test_precomputed_and_scanned_browser_agree_for_double_extension(self):record = self.record('Repo/A', 'poster.jpg', ['docs'], 1)record['Extension']='jpg'app.records=[record]app.build_indexes(build_words=False)compact={'d':[], 'f':[{'n':'poster.jpg','e':'jpg','s':1,'t':record['HasTxt']}]}browser=app.decode_folder_browser_data({'Repo/A':{'docs':compact}})with mock.patch.object(app,'folder_browser_data',browser):indexed=app.get_folder_contents('Repo/A','docs')with mock.patch.object(app,'folder_browser_data',{}):scanned=app.get_folder_contents('Repo/A','docs')self.assertEqual(indexed,scanned)self.assertTrue(indexed['files'][0]['link'].endswith('/docs/poster.jpg.jpg'))def test_search_timing_logs_first_and_slow_requests_without_query_content(self):with mock.patch.object(app, "_search_logged_generation", None), mock.patch("builtins.print") as log:app.search("private-query")
backend/app.py+22-5
backend/record_metadata.py+3-1
static/app.js+2-1
tests/test_data_decoding.py+12-2
tests/test_fastapi_endpoints.py+52-3
tests/test_reader_index_warming.py+15-1
tests/test_reader_navigation_host.py+17
tests/test_search.py+14