Skip to content

Commit

Permalink
refactor: remove unuse impl in alist storage
Browse files Browse the repository at this point in the history
  • Loading branch information
krau committed Nov 20, 2024
1 parent 5b775a2 commit 6ec7d57
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions storage/alist/alist.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,6 @@ func (a *Alist) GetFile(ctx context.Context, detail *types.StorageDetail) ([]byt
return os.ReadFile(cachePath)
}

type AutoCleanRC struct {
io.ReadCloser
name string
}

func (a *AutoCleanRC) Name() string {
return a.name
}

func (a *AutoCleanRC) Close() error {
err := a.ReadCloser.Close()
if err != nil {
return err
}
go common.RmFileAfter(a.Name(), time.Duration(config.Cfg.Storage.CacheTTL)*time.Second)
return nil
}

func (a *Alist) GetFileStream(ctx context.Context, detail *types.StorageDetail) (io.ReadCloser, error) {
common.Logger.Debugf("Getting file %s", detail.Path)
cachePath := path.Join(config.Cfg.Storage.CacheDir, filepath.Base(detail.Path))
Expand Down Expand Up @@ -171,10 +153,7 @@ func (a *Alist) GetFileStream(ctx context.Context, detail *types.StorageDetail)
common.Logger.Errorf("failed to save file: %s", err)
return nil, err
}
return &AutoCleanRC{
ReadCloser: resp.Body,
name: cachePath,
}, nil
return resp.Body, nil
}

func (a *Alist) Delete(ctx context.Context, detail *types.StorageDetail) error {
Expand Down

0 comments on commit 6ec7d57

Please sign in to comment.