@@ -427,38 +427,6 @@ class SearchBackend {
427
427
}
428
428
}
429
429
430
- /// Downloads the remote SDK content from [uri] and creates a cached file in the
431
- /// `.dart_tool/pub-search-data/` directory.
432
- ///
433
- /// When a local file in `app/.dart_tool/pub-search-data/<reduced-uri>` exists,
434
- /// its content will be loaded instead. URL reduction replaces slashes and other
435
- /// non-characters with a single dash `-` , like:
436
- /// - `https-api.dart.dev-stable-latest-index.json`
437
- Future <String > loadOrFetchSdkIndexJsonAsString (
438
- Uri uri, {
439
- @visibleForTesting Duration ? ttl,
440
- }) async {
441
- final fileName = uri.toString ().replaceAll (RegExp (r'[^a-z0-9\.]+' ), '-' );
442
- final file = File (p.join ('.dart_tool' , 'pub-search-data' , fileName));
443
- if (await file.exists ()) {
444
- var canUseCached = true ;
445
- if (ttl != null ) {
446
- final age = clock.now ().difference (await file.lastModified ());
447
- if (age > ttl) {
448
- canUseCached = false ;
449
- }
450
- }
451
- if (canUseCached) {
452
- return await file.readAsString ();
453
- }
454
- }
455
-
456
- final content = await httpGetWithRetry (uri, responseFn: (rs) => rs.body);
457
- await file.parent.create (recursive: true );
458
- await file.writeAsString (content);
459
- return content;
460
- }
461
-
462
430
Future <List <PackageDocument >?> fetchSnapshotDocuments () async {
463
431
try {
464
432
final map = await _snapshotStorage.getContentAsJsonMap ();
@@ -609,6 +577,38 @@ List<ApiDocPage> apiDocPagesFromPubData(PubDartdocData pubData) {
609
577
return results;
610
578
}
611
579
580
+ /// Downloads the remote SDK content from [uri] and creates a cached file in the
581
+ /// `.dart_tool/pub-search-data/` directory.
582
+ ///
583
+ /// When a local file in `app/.dart_tool/pub-search-data/<reduced-uri>` exists,
584
+ /// its content will be loaded instead. URL reduction replaces slashes and other
585
+ /// non-characters with a single dash `-` , like:
586
+ /// - `https-api.dart.dev-stable-latest-index.json`
587
+ Future <String > loadOrFetchSdkIndexJsonAsString (
588
+ Uri uri, {
589
+ @visibleForTesting Duration ? ttl,
590
+ }) async {
591
+ final fileName = uri.toString ().replaceAll (RegExp (r'[^a-z0-9\.]+' ), '-' );
592
+ final file = File (p.join ('.dart_tool' , 'pub-search-data' , fileName));
593
+ if (await file.exists ()) {
594
+ var canUseCached = true ;
595
+ if (ttl != null ) {
596
+ final age = clock.now ().difference (await file.lastModified ());
597
+ if (age > ttl) {
598
+ canUseCached = false ;
599
+ }
600
+ }
601
+ if (canUseCached) {
602
+ return await file.readAsString ();
603
+ }
604
+ }
605
+
606
+ final content = await httpGetWithRetry (uri, responseFn: (rs) => rs.body);
607
+ await file.parent.create (recursive: true );
608
+ await file.writeAsString (content);
609
+ return content;
610
+ }
611
+
612
612
class _CombinedSearchIndex implements SearchIndex {
613
613
const _CombinedSearchIndex ();
614
614
0 commit comments