|
|
|
@@ -41,9 +41,9 @@ type Attachment struct { |
|
|
|
UploaderID int64 `xorm:"INDEX DEFAULT 0"` // Notice: will be zero before this column added |
|
|
|
CommentID int64 |
|
|
|
Name string |
|
|
|
Description string `xorm:"TEXT"` |
|
|
|
DownloadCount int64 `xorm:"DEFAULT 0"` |
|
|
|
UseCount int64 |
|
|
|
Description string `xorm:"TEXT"` |
|
|
|
DownloadCount int64 `xorm:"DEFAULT 0"` |
|
|
|
UseCount int64 `xorm:"DEFAULT 0"` |
|
|
|
Size int64 `xorm:"DEFAULT 0"` |
|
|
|
IsPrivate bool `xorm:"DEFAULT false"` |
|
|
|
DecompressState int32 `xorm:"DEFAULT 0"` |
|
|
|
@@ -108,6 +108,15 @@ func (a *Attachment) IncreaseDownloadCount() error { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func IncreaseAttachmentUseCount(uuid string) error { |
|
|
|
// Update use count. |
|
|
|
if _, err := x.Exec("UPDATE `attachment` SET use_count=use_count+1 WHERE uuid=?", uuid); err != nil { |
|
|
|
return fmt.Errorf("increase attachment use count: %v", err) |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func (a *Attachment) UpdateDatasetUpdateUnix() error { |
|
|
|
// Update download count. |
|
|
|
if _, err := x.Exec("UPDATE `dataset` SET updated_unix="+fmt.Sprint(time.Now().Unix())+" WHERE id=?", a.DatasetID); err != nil { |
|
|
|
|