mirror of
https://github.com/usememos/memos.git
synced 2025-03-15 18:20:09 +01:00
chore: tweak package name
This commit is contained in:
parent
da535c8dc6
commit
dfc0889a4f
@ -1,4 +0,0 @@
|
||||
// Package getter is using to get resources from url.
|
||||
// * Get metadata for website;
|
||||
// * Get image blob to avoid CORS;
|
||||
package getter
|
@ -1,4 +1,4 @@
|
||||
package getter
|
||||
package httpgetter
|
||||
|
||||
import (
|
||||
"errors"
|
@ -1,4 +1,4 @@
|
||||
package getter
|
||||
package httpgetter
|
||||
|
||||
import (
|
||||
"testing"
|
4
plugin/httpgetter/http_getter.go
Normal file
4
plugin/httpgetter/http_getter.go
Normal file
@ -0,0 +1,4 @@
|
||||
// Package httpgetter is using to get resources from url.
|
||||
// * Get metadata for website;
|
||||
// * Get image blob to avoid CORS;
|
||||
package httpgetter
|
@ -1,4 +1,4 @@
|
||||
package getter
|
||||
package httpgetter
|
||||
|
||||
import (
|
||||
"errors"
|
@ -1,4 +1,4 @@
|
||||
package getter
|
||||
package httpgetter
|
||||
|
||||
import (
|
||||
"mime"
|
@ -15,10 +15,6 @@ import (
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
||||
// presignLifetimeSecs is the lifetime of a presigned URL in seconds.
|
||||
// The presigned URL is valid for 7 days.
|
||||
const presignLifetimeSecs = 7 * 24 * 60 * 60
|
||||
|
||||
type Client struct {
|
||||
Client *s3.Client
|
||||
Bucket *string
|
||||
@ -74,7 +70,7 @@ func (c *Client) PresignGetObject(ctx context.Context, key string) (string, erro
|
||||
Bucket: aws.String(*c.Bucket),
|
||||
Key: aws.String(key),
|
||||
}, func(opts *s3.PresignOptions) {
|
||||
opts.Expires = time.Duration(presignLifetimeSecs * int64(time.Second))
|
||||
opts.Expires = time.Duration(7 * 24 * time.Hour)
|
||||
})
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "failed to presign put object")
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/yourselfhosted/gomark/parser/tokenizer"
|
||||
"github.com/yourselfhosted/gomark/restore"
|
||||
|
||||
getter "github.com/usememos/memos/plugin/http-getter"
|
||||
"github.com/usememos/memos/plugin/httpgetter"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
)
|
||||
|
||||
@ -33,7 +33,7 @@ func (*APIV1Service) RestoreMarkdown(_ context.Context, request *v1pb.RestoreMar
|
||||
}
|
||||
|
||||
func (*APIV1Service) GetLinkMetadata(_ context.Context, request *v1pb.GetLinkMetadataRequest) (*v1pb.LinkMetadata, error) {
|
||||
htmlMeta, err := getter.GetHTMLMeta(request.Link)
|
||||
htmlMeta, err := httpgetter.GetHTMLMeta(request.Link)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -53,8 +53,9 @@ func (p *S3ObjectPresigner) CheckAndPresign(ctx context.Context) {
|
||||
}
|
||||
|
||||
if s3ObjectPayload.LastPresignedTime != nil {
|
||||
// Skip if the presigned URL is still valid.
|
||||
if time.Now().Before(s3ObjectPayload.LastPresignedTime.AsTime().Add(24 * time.Hour)) {
|
||||
// Skip if the presigned URL is still valid for the next 6 days.
|
||||
// The default expiration time is 7 days.
|
||||
if time.Now().Before(s3ObjectPayload.LastPresignedTime.AsTime().Add(6 * 24 * time.Hour)) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user