Skip to content
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

Custom storage implementation #183

Closed
mitar opened this issue Dec 28, 2024 · 5 comments
Closed

Custom storage implementation #183

mitar opened this issue Dec 28, 2024 · 5 comments

Comments

@mitar
Copy link

mitar commented Dec 28, 2024

Any plans to support custom storage implementations, so that I could store files into cloud storage for example? Or even memory? It seems that for memory I could use a tmpfs mount point and then direct the library to store everything there, but having things in Go process might be easier to track/account memory usage to the program.

@cenkalti
Copy link
Owner

There isn't built-in support for custom storage implementations. However, I've made a small change to make it easier to modify in the code and build yourself.

Storage appears as an interface to the client:
https://github.com/cenkalti/rain/blob/master/internal/storage/storage.go

If you are willing to write some code, this line is where you should start:

rain/torrent/session.go

Lines 448 to 450 in e8a4831

func (s *Session) newStorage(id string) (storage.Storage, error) {
return filestorage.New(s.getDataDir(id), s.config.FilePermissions)
}

Please let me know if you have questions.

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Jan 30, 2025
@mitar
Copy link
Author

mitar commented Jan 30, 2025

@cenkalti This is cool. Do you think newStorage could be exposed as a callback on Config? Then it would be easy for me to implement the interface without having to fork the code.

@github-actions github-actions bot removed the stale label Jan 31, 2025
cenkalti added a commit that referenced this issue Feb 2, 2025
@cenkalti
Copy link
Owner

cenkalti commented Feb 2, 2025

I added:

rain/torrent/config.go

Lines 205 to 206 in f14dfc0

// Replace default storage provider
CustomStorage storage.Provider `yaml:"-"`

Does that work for you?

@mitar
Copy link
Author

mitar commented Feb 3, 2025

This looks great, thanks!

@cenkalti cenkalti closed this as completed Feb 4, 2025
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

No branches or pull requests

2 participants