Drop-in replace local read-only files with ipfs & symlinks?

Looking for advice/warnings about doing the following.

I have a read-only file structure accessed through software I can’t easily update. I want to make this software use ipfs. Why?

  1. All these files are growing too big to fit in one place, so I plan to pin across other nodes, and then allow this one to cache from them as needed.
  2. I want to push these files into IPFS so I can access from other nodes anyway.

My plan is to add each file to ipfs and then replace it with a symlink to the hash under my /ipfs mount. The end result will be a directory structure with no actual files, just symlinks.

For each file, it would be something like:

# ipfs-ify.sh
hash=`ipfs add $filename`
rm $filename
ln -s /ipfs/$hash $filename

So I’ll use this + find to replace a directory recursively:

find /my/old/filestructure/root -type f -exec ipfs-ify.sh {} \;

Will this work? It seems to good to be true…

1 Like

I am interested in this use case as well. Have you tried it out yet?

I have only tried it with a few test files, and it seems to work well enough.

However I now think this approach may be over-complicating things. Isn’t the end result here equivalent to pushing the whole directory into ipfs and then symlinking the folder?

hash=`ipfs add -r /my/old/filestructure/root | tail -1`
rm -rf /my/old/filestructure/root
ln -s /ipfs/$hash /my/old/filestructure/root