소스 검색

GOFMT

tags/v1.2.0
Andrea Spacca 3 년 전
부모
커밋
d3381a2293
3개의 변경된 파일15개의 추가작업 그리고 17개의 파일을 삭제
  1. +1
    -2
      cmd/cmd.go
  2. +2
    -3
      server/server.go
  3. +12
    -12
      server/storage.go

+ 1
- 2
cmd/cmd.go 파일 보기

@@ -377,10 +377,9 @@ func New() *Cmd {
options = append(options, server.RateLimit(v)) options = append(options, server.RateLimit(v))
} }



purgeDays := c.Int("purge-days") purgeDays := c.Int("purge-days")
purgeInterval := c.Int("purge-interval") purgeInterval := c.Int("purge-interval")
if purgeDays > 0 && purgeInterval > 0 {
if purgeDays > 0 && purgeInterval > 0 {
options = append(options, server.Purge(purgeDays, purgeInterval)) options = append(options, server.Purge(purgeDays, purgeInterval))
} }




+ 2
- 3
server/server.go 파일 보기

@@ -194,7 +194,6 @@ func Purge(days, interval int) OptionFn {
} }
} }



func ForceHTTPs() OptionFn { func ForceHTTPs() OptionFn {
return func(srvr *Server) { return func(srvr *Server) {
srvr.forceHTTPs = true srvr.forceHTTPs = true
@@ -288,8 +287,8 @@ type Server struct {
maxUploadSize int64 maxUploadSize int64
rateLimitRequests int rateLimitRequests int


purgeDays time.Duration
purgeInterval time.Duration
purgeDays time.Duration
purgeInterval time.Duration


storage Storage storage Storage




+ 12
- 12
server/storage.go 파일 보기

@@ -158,12 +158,12 @@ func NewS3Storage(accessKey, secretKey, bucketName string, purgeDays int, region
sess := getAwsSession(accessKey, secretKey, region, endpoint, forcePathStyle) sess := getAwsSession(accessKey, secretKey, region, endpoint, forcePathStyle)


return &S3Storage{ return &S3Storage{
bucket: bucketName,
s3: s3.New(sess),
session: sess,
logger: logger,
bucket: bucketName,
s3: s3.New(sess),
session: sess,
logger: logger,
noMultipart: disableMultipart, noMultipart: disableMultipart,
purgeDays: time.Duration(purgeDays * 24) * time.Hour,
purgeDays: time.Duration(purgeDays*24) * time.Hour,
}, nil }, nil
} }


@@ -274,9 +274,9 @@ func (s *S3Storage) Put(token string, filename string, reader io.Reader, content
}) })


_, err = uploader.Upload(&s3manager.UploadInput{ _, err = uploader.Upload(&s3manager.UploadInput{
Bucket: aws.String(s.bucket),
Key: aws.String(key),
Body: reader,
Bucket: aws.String(s.bucket),
Key: aws.String(key),
Body: reader,
Expires: aws.Time(time.Now().Add(s.purgeDays)), Expires: aws.Time(time.Now().Add(s.purgeDays)),
}) })


@@ -616,10 +616,10 @@ func saveGDriveToken(path string, token *oauth2.Token, logger *log.Logger) {


type StorjStorage struct { type StorjStorage struct {
Storage Storage
project *uplink.Project
bucket *uplink.Bucket
project *uplink.Project
bucket *uplink.Bucket
purgeDays time.Duration purgeDays time.Duration
logger *log.Logger
logger *log.Logger
} }


func NewStorjStorage(access, bucket string, purgeDays int, logger *log.Logger) (*StorjStorage, error) { func NewStorjStorage(access, bucket string, purgeDays int, logger *log.Logger) (*StorjStorage, error) {
@@ -645,7 +645,7 @@ func NewStorjStorage(access, bucket string, purgeDays int, logger *log.Logger) (
return nil, err return nil, err
} }


instance.purgeDays = time.Duration(purgeDays * 24) * time.Hour
instance.purgeDays = time.Duration(purgeDays*24) * time.Hour


instance.logger = logger instance.logger = logger




불러오는 중...
취소
저장