fix: skip socket files in ipfs add to prevent errors #11149
Draft
+169
−0
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.
Fix: Gracefully Skip Socket Files in
ipfs addContext
When running
ipfs addon a directory that contains socket files, the operation fails with a misleading error:use of closed network connection. This breaks bulk add operations if a socket file is accidentally included (e.g., in a development directory) and prevents users from adding the rest of their files.Goal
The objective is to silently ignore unrecognized file types (specifically socket files) during the
ipfs addprocess. This ensures thatipfs addbehaves robustly, similar to how it handles other non-supported file types, and allows the operation to proceed for all valid files.Implementation Details
client/rpc/unixfs.go
We implemented a wrapper around the standard file directory iterator to catch and handle specific errors.
files.Directorythat acts as a factory for our custom iterator.DirIterator.client/rpc/unixfs_test.go
Added a new test file to verify this behavior isolation.
ipfs addcommand, ensuring the fix works in the real pipeline.Verification
Automated Tests
Run the new verification tests:
go test -v ./client/rpc -run TestSkippingIterator