Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
j2rong4cn committed Jan 22, 2025
1 parent 6dff552 commit 50ad1da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
10 changes: 5 additions & 5 deletions internal/op/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ func getArchiveMeta(ctx context.Context, storage driver.Driver, path string, arg
if meta.GetTree() != nil {
archiveMetaProvider.Sort = &storage.GetStorage().Sort
}
if ss.Link.MFile == nil {
if !storage.Config().NoCache {
Expiration := time.Minute * time.Duration(storage.GetStorage().CacheExpiration)
archiveMetaProvider.Expiration = &Expiration
} else if ss.Link.MFile == nil {
// alias、crypt 驱动
archiveMetaProvider.Expiration = ss.Link.Expiration
if archiveMetaProvider.Expiration == nil && !storage.Config().NoCache {
Expiration := time.Minute * time.Duration(storage.GetStorage().CacheExpiration)
archiveMetaProvider.Expiration = &Expiration
}
}
return obj, archiveMetaProvider, err
}
Expand Down
7 changes: 2 additions & 5 deletions internal/stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func NewSeekableStream(fs FileStream, link *model.Link) (*SeekableStream, error)

if ss.Link.RangeReadCloser != nil {
ss.rangeReadCloser = ss.Link.RangeReadCloser
ss.Add(ss.rangeReadCloser)
return &ss, nil
}
if len(ss.Link.URL) > 0 {
Expand All @@ -196,6 +197,7 @@ func NewSeekableStream(fs FileStream, link *model.Link) (*SeekableStream, error)
return nil, err
}
ss.rangeReadCloser = rrc
ss.Add(rrc)
return &ss, nil
}
}
Expand Down Expand Up @@ -247,8 +249,6 @@ func (ss *SeekableStream) Read(p []byte) (n int, err error) {
return 0, nil
}
ss.Reader = io.NopCloser(rc)
ss.Closers.Add(rc)

}
return ss.Reader.Read(p)
}
Expand Down Expand Up @@ -384,9 +384,6 @@ func (r *RangeReadReadAtSeeker) getReaderAtOffset(off int64) (*readerCur, error)
if err != nil {
return nil, err
}
if c, ok := reader.(io.Closer); ok {
r.ss.Closers.Add(c)
}
rc := &readerCur{reader: reader, cur: off}
r.readers = append(r.readers, rc)
return rc, nil
Expand Down

0 comments on commit 50ad1da

Please sign in to comment.