Skip to content

Commit

Permalink
feat: less strict tmp url download
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliothmoon committed Jan 23, 2025
1 parent 9cad95a commit d381486
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions internal/handler/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ func (h *VersionHandler) Download(c *fiber.Ctx) error {
return c.Status(fiber.StatusNotFound).JSON(resp)
}

h.logger.Info("start download resources", zap.String("ip", c.IP()))

// full update
getResourcePathParam := GetResourcePathParam{
ResourceID: info.ResourceID,
Expand Down
5 changes: 2 additions & 3 deletions internal/logic/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ func (l *VersionLogic) Create(ctx context.Context, param CreateVersionParam) (*e
l.logger.Error("Unknown archive extension",
zap.String("archive path", param.UploadArchivePath),
)
err = fmt.Errorf("Unknown archive extension")
return err
return errors.New("unknown archive extension")
}

tx.OnRollback(func(next ent.Rollbacker) ent.Rollbacker {
Expand Down Expand Up @@ -250,7 +249,7 @@ func (l *VersionLogic) StoreTempDownloadInfo(ctx context.Context, param StoreTem
key := ksuid.New().String()
rk := fmt.Sprintf("RES:%v", key)

err = l.tempDownloadInfoRepo.SetTempDownloadInfo(ctx, rk, info, 20*time.Minute)
err = l.tempDownloadInfoRepo.SetTempDownloadInfo(ctx, rk, info, 10*time.Minute)
if err != nil {
l.logger.Error("Failed to set temp download info",
zap.Error(err),
Expand Down
2 changes: 1 addition & 1 deletion internal/repo/temp_download_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewTempDownloadInfo(rdb *redis.Client) *TempDownloadInfo {
}

func (r *TempDownloadInfo) GetDelTempDownloadInfo(ctx context.Context, key string) (*model.TempDownloadInfo, error) {
val, err := r.rdb.GetDel(ctx, key).Result()
val, err := r.rdb.Get(ctx, key).Result()
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func main() {
handlerSet := wire.NewHandlerSet(conf, l, mySQL, redis, storage)

app := fiber.New(fiber.Config{
BodyLimit: BodyLimit,
BodyLimit: BodyLimit,
ProxyHeader: fiber.HeaderXForwardedFor,
})
app.Use(fiberzap.New(fiberzap.Config{
Logger: l,
Expand Down

0 comments on commit d381486

Please sign in to comment.