mirror of
https://github.com/restic/restic.git
synced 2026-09-19 02:37:58 +00:00
Add []byte to repo.LoadAndDecrypt and utils.LoadAll
This commit changes the signatures for repository.LoadAndDecrypt and utils.LoadAll to allow passing in a []byte as the buffer to use. This buffer is enlarged as needed, and returned back to the caller for further use. In later commits, this allows reducing allocations by reusing a buffer for multiple calls, e.g. in a worker function.
This commit is contained in:
@@ -39,8 +39,11 @@ type Repository interface {
|
||||
SaveUnpacked(context.Context, FileType, []byte) (ID, error)
|
||||
SaveJSONUnpacked(context.Context, FileType, interface{}) (ID, error)
|
||||
|
||||
LoadJSONUnpacked(context.Context, FileType, ID, interface{}) error
|
||||
LoadAndDecrypt(context.Context, FileType, ID) ([]byte, error)
|
||||
LoadJSONUnpacked(ctx context.Context, t FileType, id ID, dest interface{}) error
|
||||
// LoadAndDecrypt loads and decrypts the file with the given type and ID,
|
||||
// using the supplied buffer (which must be empty). If the buffer is nil, a
|
||||
// new buffer will be allocated and returned.
|
||||
LoadAndDecrypt(ctx context.Context, buf []byte, t FileType, id ID) (data []byte, err error)
|
||||
|
||||
LoadBlob(context.Context, BlobType, ID, []byte) (int, error)
|
||||
SaveBlob(context.Context, BlobType, []byte, ID) (ID, error)
|
||||
|
||||
Reference in New Issue
Block a user