feat: 115网盘离线索引功能#23
Open
power721 wants to merge 8 commits into
Open
Conversation
- Implement MapPath function to remove emoji prefix from webdavsim paths - Add comprehensive test coverage for path mapping - Define core data structures: IndexNode, ImportBatchRequest, ImportBatchResponse, SearchRequest, SearchResponse, SearchNode - All tests passing
- Remove DirOnly/FileOnly fields from SearchRequest, replace with Scope field (0=all, 1=folder, 2=file) - Add package documentation explaining 115 cloud storage indexing purpose - Enhance MapPath documentation to clarify webdavsim-specific emoji handling - Add test cases documenting that other emojis pass through unchanged
- Add Service struct with bleve.Index for 115 indexing - Implement NewService: creates/opens bleve index at dataDir/indexes/115 - Implement BatchIndex: batch imports nodes with MapPath transformation - Implement Close method for proper resource cleanup - Add comprehensive tests: - TestServiceBatchIndex: verifies batch indexing with emoji paths - TestServiceClose: verifies index can be closed and reopened - All tests pass, path mapping correctly removes emoji prefix
Implemented critical fixes and improvements to the bleve index service: **Critical Fixes:** - Add nil check in BatchIndex to prevent panics after Close() - Replace random UUIDs with deterministic SHA-256 path hashes for idempotent indexing - Implement batch chunking (10k documents/chunk) to prevent memory exhaustion - Fix indexed counter logic - return 0 if batch.Index() fails **Minor Improvements:** - Remove unused dataDir field from Service struct - Replace defer os.RemoveAll() with t.Cleanup() in tests **New Test Coverage:** - TestBatchIndexAfterClose: verifies error when indexing after close - TestIdempotentIndexing: verifies path-based deduplication works - TestLargeBatchChunking: verifies 25k nodes processed correctly in chunks All tests pass (6/6 test functions, 10/10 subtests). Co-Authored-By: Claude Sonnet 4.6 (200k context) <noreply@anthropic.com>
Add Search method with pagination and field extraction: - Search on path field using bleve MatchQuery - Default MaxResults=20, capped at 100 - Sort by indexed_at descending - Extract path, name, size, is_dir fields - Return SearchResponse with Total and Results Add Clear method to reset index: - Close current index - Delete index directory - Create new empty index Add comprehensive tests: - TestServiceSearch: verify search returns matching files - TestServiceSearchPagination: verify pagination works correctly - TestServiceClear: verify Clear empties the index All tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Critical fixes: - Change pagination from MaxResults/Offset to Page/PerPage (1-based) - Implement Scope filtering (0=all, 1=folders, 2=files) - Remove non-spec fields: Success, Message from SearchResponse - Remove non-spec fields: Modified, ParentPath, Score from SearchNode Changes: - model.go: Update SearchRequest to use Page/PerPage, clean response models - service.go: Calculate offset as (Page-1)*PerPage, add scope filtering logic - service_test.go: Update all tests to use new pagination, add scope tests All tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Create server/handles/alist115.go with three handlers: * Alist115ImportBatch: POST /api/fs/115/import-batch (admin only) * Alist115Search: GET/POST /api/fs/115/search (authenticated users) * Alist115Clear: DELETE /api/fs/115/clear (admin only) - Register routes in server/router.go under /api/fs/115 - Add bootstrap initialization: * Create internal/bootstrap/alist115.go * Call InitAlist115() in bootstrap.Init() - Add API documentation in docs/115-indexing-api.md All handlers follow existing patterns: - User authentication via conf.UserKey - Admin permission checks for import/clear - Error handling with common.ErrorResp - Success responses with common.SuccessResp Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
如果跨多个组件,请使用主要组件作为前缀,并在标题中枚举、描述中说明。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Key Features
Test Plan
Implementation Details
internal/search/alist115(955行代码,551行测试)server/handles/alist115.gointernal/bootstrap/alist115.godata/indexes/115/(独立于主索引)Documentation
docs/115-indexing-api.mddocs/superpowers/specs/2026-06-16-115-offline-indexing-design.md🤖 Generated with Claude Code