use the request context

This commit is contained in:
MaysWind
2025-08-02 00:10:12 +08:00
parent 56a3905df1
commit cad53d0bfc
8 changed files with 59 additions and 54 deletions
+17 -16
View File
@@ -1,6 +1,7 @@
package storage
import (
"github.com/mayswind/ezbookkeeping/pkg/core"
"github.com/mayswind/ezbookkeeping/pkg/errs"
"github.com/mayswind/ezbookkeeping/pkg/settings"
)
@@ -41,43 +42,43 @@ func InitializeStorageContainer(config *settings.Config) error {
}
// ExistsAvatar returns whether the avatar file exists from the current avatar object storage
func (s *StorageContainer) ExistsAvatar(path string) (bool, error) {
return s.AvatarCurrentStorage.Exists(path)
func (s *StorageContainer) ExistsAvatar(ctx core.Context, path string) (bool, error) {
return s.AvatarCurrentStorage.Exists(ctx, path)
}
// ReadAvatar returns the avatar file from the current avatar object storage
func (s *StorageContainer) ReadAvatar(path string) (ObjectInStorage, error) {
return s.AvatarCurrentStorage.Read(path)
func (s *StorageContainer) ReadAvatar(ctx core.Context, path string) (ObjectInStorage, error) {
return s.AvatarCurrentStorage.Read(ctx, path)
}
// SaveAvatar returns whether save the avatar file into the current avatar object storage successfully
func (s *StorageContainer) SaveAvatar(path string, object ObjectInStorage) error {
return s.AvatarCurrentStorage.Save(path, object)
func (s *StorageContainer) SaveAvatar(ctx core.Context, path string, object ObjectInStorage) error {
return s.AvatarCurrentStorage.Save(ctx, path, object)
}
// DeleteAvatar returns whether delete the avatar file from the current avatar object storage successfully
func (s *StorageContainer) DeleteAvatar(path string) error {
return s.AvatarCurrentStorage.Delete(path)
func (s *StorageContainer) DeleteAvatar(ctx core.Context, path string) error {
return s.AvatarCurrentStorage.Delete(ctx, path)
}
// ExistsTransactionPicture returns whether the transaction picture file exists from the current transaction picture object storage
func (s *StorageContainer) ExistsTransactionPicture(path string) (bool, error) {
return s.TransactionPictureCurrentStorage.Exists(path)
func (s *StorageContainer) ExistsTransactionPicture(ctx core.Context, path string) (bool, error) {
return s.TransactionPictureCurrentStorage.Exists(ctx, path)
}
// ReadTransactionPicture returns the transaction picture file from the current transaction picture object storage
func (s *StorageContainer) ReadTransactionPicture(path string) (ObjectInStorage, error) {
return s.TransactionPictureCurrentStorage.Read(path)
func (s *StorageContainer) ReadTransactionPicture(ctx core.Context, path string) (ObjectInStorage, error) {
return s.TransactionPictureCurrentStorage.Read(ctx, path)
}
// SaveTransactionPicture returns whether save the transaction picture file into the current transaction picture object storage successfully
func (s *StorageContainer) SaveTransactionPicture(path string, object ObjectInStorage) error {
return s.TransactionPictureCurrentStorage.Save(path, object)
func (s *StorageContainer) SaveTransactionPicture(ctx core.Context, path string, object ObjectInStorage) error {
return s.TransactionPictureCurrentStorage.Save(ctx, path, object)
}
// DeleteTransactionPicture returns whether delete the transaction picture file from the current transaction picture object storage successfully
func (s *StorageContainer) DeleteTransactionPicture(path string) error {
return s.TransactionPictureCurrentStorage.Delete(path)
func (s *StorageContainer) DeleteTransactionPicture(ctx core.Context, path string) error {
return s.TransactionPictureCurrentStorage.Delete(ctx, path)
}
func newObjectStorage(config *settings.Config, pathPrefix string) (ObjectStorage, error) {