mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-07 13:33:24 +09:00
This commit is contained in:
@@ -4,11 +4,14 @@
|
||||
package packages
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"io/fs"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"gitea.dev/modules/optional"
|
||||
"gitea.dev/modules/setting"
|
||||
"gitea.dev/modules/storage"
|
||||
"gitea.dev/modules/util"
|
||||
@@ -47,6 +50,17 @@ func (s *ContentStore) Has(key BlobHash256Key) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *ContentStore) OptionalSize(key BlobHash256Key) (sz optional.Option[int64], _ error) {
|
||||
st, err := s.store.Stat(KeyToRelativePath(key))
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return sz, nil
|
||||
}
|
||||
if err != nil {
|
||||
return sz, err
|
||||
}
|
||||
return optional.Some(st.Size()), nil
|
||||
}
|
||||
|
||||
// Save stores a package blob
|
||||
func (s *ContentStore) Save(key BlobHash256Key, r io.Reader, size int64) error {
|
||||
_, err := s.store.Save(KeyToRelativePath(key), r, size)
|
||||
|
||||
Reference in New Issue
Block a user