fix: force fresh API fetch on readdir to surface new remote files - #4
Open
amlucas0xff wants to merge 1 commit into
Open
fix: force fresh API fetch on readdir to surface new remote files#4amlucas0xff wants to merge 1 commit into
amlucas0xff wants to merge 1 commit into
Conversation
DriveNode.get_children() has two layers of in-memory cache: - self.data["items"]: raw API response populated on first fetch - self._children: parsed DriveNode objects built from data["items"] Previously, neither was ever cleared. Files added remotely (e.g. from iOS) would never appear in a mounted directory until the service restarted, because get_children() skips the API call when "items" is already present in self.data. Clear both caches before listing in readdir() so every directory listing fetches fresh data from the iCloud API.
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.
Problem
Files added remotely (e.g. from an iOS device) never appear in a mounted iCloud Drive directory until the FUSE service is restarted.
Root Cause
pyicloud'sDriveNode.get_children()maintains two layers of in-memory cache:self.data["items"]— raw API response, populated on first fetchself._children— parsedDriveNodeobjects built fromdata["items"]get_children()only calls the API when"items"is absent fromself.data. Once populated, both caches are never cleared, so the directory listing becomes permanently stale for the lifetime of the process.Resetting only
self._childrenis insufficient — it rebuilds children from the same staledata["items"]without making a new API call.Fix
In
readdir(), evict both cache layers before listing:This forces
get_children()to re-fetch directory contents from the iCloud API on everyreaddircall, so new files added remotely appear immediately on the next directory access without requiring a service restart.Trade-off
Every directory listing now makes an API call. For typical interactive use (browsing,
ls) this is acceptable. For high-frequency automated access, a TTL-based invalidation strategy would be preferable.