Skip to content

Conversation

@ktock
Copy link
Member

@ktock ktock commented Jan 24, 2025

Close #1948

Thanks @ChengyuZhu6 for the refactoring patch, I'm going to merge that here with adding a tiny fix.

This commit refactors the blob handling code to improve code organization.
The changes include:

1. Extract chunk handling logic into separate functions:
   - prepareChunksForRead: Prepare chunks for reading
   - readFromCache: Handle cache reading
   - cacheChunkData: Handle chunk caching
   - handleSharedFetch: Handle shared fetch scenarios
   - copyFetchedChunks: Copy fetched chunks

2. Improve error handling:
   - Add more descriptive error messages
   - Consistent error wrapping using fmt.Errorf
   - Maintain same error handling behavior

3. Keep original behavior:
   - Maintain same data flow
   - Keep same concurrency control
   - No additional memory allocations
   - Same caching mechanism

4. Code organization improvements:
   - Single responsibility functions
   - Clear function names
   - Better code readability
   - Easier to maintain and test

Signed-off-by: ChengyuZhu6 <[email protected]>
Signed-off-by: Kohei Tokunaga <[email protected]>
@AkihiroSuda AkihiroSuda merged commit 6378393 into containerd:main Feb 13, 2025
31 checks passed
@ktock ktock deleted the carrying-1948 branch February 15, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants