| @@ -28,19 +28,19 @@ const ( | |||||
| // Attachment represent a attachment of issue/comment/release. | // Attachment represent a attachment of issue/comment/release. | ||||
| type Attachment struct { | type Attachment struct { | ||||
| ID int64 `xorm:"pk autoincr"` | |||||
| UUID string `xorm:"uuid UNIQUE"` | |||||
| IssueID int64 `xorm:"INDEX"` | |||||
| DatasetID int64 `xorm:"INDEX DEFAULT 0"` | |||||
| ReleaseID int64 `xorm:"INDEX"` | |||||
| UploaderID int64 `xorm:"INDEX DEFAULT 0"` // Notice: will be zero before this column added | |||||
| CommentID int64 | |||||
| Name string | |||||
| DownloadCount int64 `xorm:"DEFAULT 0"` | |||||
| Size int64 `xorm:"DEFAULT 0"` | |||||
| IsPrivate bool `xorm:"DEFAULT false"` | |||||
| DecompressState int32 `xorm:"DEFAULT 0"` | |||||
| CreatedUnix timeutil.TimeStamp `xorm:"created"` | |||||
| ID int64 `xorm:"pk autoincr"` | |||||
| UUID string `xorm:"uuid UNIQUE"` | |||||
| IssueID int64 `xorm:"INDEX"` | |||||
| DatasetID int64 `xorm:"INDEX DEFAULT 0"` | |||||
| ReleaseID int64 `xorm:"INDEX"` | |||||
| UploaderID int64 `xorm:"INDEX DEFAULT 0"` // Notice: will be zero before this column added | |||||
| CommentID int64 | |||||
| Name string | |||||
| DownloadCount int64 `xorm:"DEFAULT 0"` | |||||
| Size int64 `xorm:"DEFAULT 0"` | |||||
| IsPrivate bool `xorm:"DEFAULT false"` | |||||
| DecompressState int32 `xorm:"DEFAULT 0"` | |||||
| CreatedUnix timeutil.TimeStamp `xorm:"created"` | |||||
| } | } | ||||
| func (a *Attachment) AfterUpdate() { | func (a *Attachment) AfterUpdate() { | ||||
| @@ -7,15 +7,15 @@ import ( | |||||
| ) | ) | ||||
| const ( | const ( | ||||
| DecompressTimer = time.Minute * 10 | |||||
| DecompressTimer = time.Minute * 10 | |||||
| ) | ) | ||||
| func init() { | func init() { | ||||
| ticker := time.NewTicker(DecompressTimer) | ticker := time.NewTicker(DecompressTimer) | ||||
| go func() { | go func() { | ||||
| for { | for { | ||||
| <- ticker.C | |||||
| <-ticker.C | |||||
| repo.HandleUnDecompressAttachment() | repo.HandleUnDecompressAttachment() | ||||
| } | } | ||||
| } () | |||||
| }() | |||||
| } | } | ||||
| @@ -24,8 +24,8 @@ import ( | |||||
| const ( | const ( | ||||
| //result of decompress | //result of decompress | ||||
| DecompressSuccess = "0" | |||||
| DecompressFailed = "1" | |||||
| DecompressSuccess = "0" | |||||
| DecompressFailed = "1" | |||||
| ) | ) | ||||
| func RenderAttachmentSettings(ctx *context.Context) { | func RenderAttachmentSettings(ctx *context.Context) { | ||||
| @@ -330,13 +330,13 @@ func UpdateAttachmentDecompressState(ctx *context.Context) { | |||||
| } | } | ||||
| func HandleUnDecompressAttachment() { | func HandleUnDecompressAttachment() { | ||||
| attachs,err := models.GetUnDecompressAttachments() | |||||
| attachs, err := models.GetUnDecompressAttachments() | |||||
| if err != nil { | if err != nil { | ||||
| log.Error("GetUnDecompressAttachments failed:", err.Error()) | log.Error("GetUnDecompressAttachments failed:", err.Error()) | ||||
| return | return | ||||
| } | } | ||||
| for _,attach := range attachs { | |||||
| for _, attach := range attachs { | |||||
| err = worker.SendDecompressTask(contexExt.Background(), attach.UUID) | err = worker.SendDecompressTask(contexExt.Background(), attach.UUID) | ||||
| if err != nil { | if err != nil { | ||||
| log.Error("SendDecompressTask(%s) failed:%s", attach.UUID, err.Error()) | log.Error("SendDecompressTask(%s) failed:%s", attach.UUID, err.Error()) | ||||