-
Notifications
You must be signed in to change notification settings - Fork 1k
Allow caching of IPFS files in file system #6031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@isum I reworked a good chunk of this, for a couple of reasons:
Sorry for troubling you again, but can you have another look at this PR? |
graph/src/ipfs/cache.rs
Outdated
} | ||
|
||
fn key(path: &ContentPath) -> String { | ||
format!("ipfs:{}", path.cid()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures that we generate the correct key for requests of files within IPFS directories
format!("ipfs:{}", path.cid()) | |
format!("ipfs:{path}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah .. yes! Nice catch!
graph/src/ipfs/cache.rs
Outdated
Cache::Disk { store } => { | ||
let log_err = |e: &object_store::Error| log_object_store_err(logger, e, false); | ||
|
||
let path = Path::from(path.cid().to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary to ensure that we retrieve the correct data
let path = Path::from(path.cid().to_string()); | |
let path = Path::from(path.to_string()); |
graph/src/ipfs/cache.rs
Outdated
} | ||
Cache::Disk { store } => { | ||
let log_err = |e: &object_store::Error| log_object_store_err(logger, e, true); | ||
let path = Path::from(path.cid().to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary to ensure that we cache the correct data
let path = Path::from(path.cid().to_string()); | |
let path = Path::from(path.to_string()); |
Get the settings for CachingClient from the environment
Since the IpsClient is now responsible for caching, we shouldn't also cache in IpfsResolver
This change adds a variable
GRAPH_IPFS_CACHE_LOCATION
, which, when set, needs to point at a directory writable bygraph-node
. All files thatgraph-node
will fetch from IPFS will be cached in that directory so that subsequent requests to fetch these files, e.g., after a restart, will use those cached files rather than issuing another IPFS request.Caching files has obvious security implications in that it is possible to modify files in the cache, and thereby change a subgraph. In other words, the cache needs to be in a trusted location with restricted access.