|
|
@@ -1,6 +1,8 @@ |
|
|
|
package models |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/timeutil" |
|
|
|
) |
|
|
|
|
|
|
@@ -29,3 +31,22 @@ func CreateDataset(dataset *Dataset) (err error) { |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
// AddReleaseAttachments adds a release attachments |
|
|
|
func AddDatasetAttachments(DatasetID int64, attachmentUUIDs []string) (err error) { |
|
|
|
// Check attachments |
|
|
|
attachments, err := GetAttachmentsByUUIDs(attachmentUUIDs) |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("GetAttachmentsByUUIDs [uuids: %v]: %v", attachmentUUIDs, err) |
|
|
|
} |
|
|
|
|
|
|
|
for i := range attachments { |
|
|
|
attachments[i].DatasetID = DatasetID |
|
|
|
// No assign value could be 0, so ignore AllCols(). |
|
|
|
if _, err = x.ID(attachments[i].ID).Update(attachments[i]); err != nil { |
|
|
|
return fmt.Errorf("update attachment [%d]: %v", attachments[i].ID, err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
} |