mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Use AfterLoad instead of AfterSet on Structs (#2628)
* use AfterLoad instead of AfterSet on Structs * fix the comments on AfterLoad * fix the comments on action AfterLoad
This commit is contained in:
parent
1ad902d529
commit
a8717e5e3a
35 changed files with 334 additions and 315 deletions
|
@ -55,24 +55,20 @@ func (m *Mirror) BeforeUpdate() {
|
|||
}
|
||||
}
|
||||
|
||||
// AfterSet is invoked from XORM after setting the value of a field of this object.
|
||||
func (m *Mirror) AfterSet(colName string, _ xorm.Cell) {
|
||||
// AfterLoad is invoked from XORM after setting the values of all fields of this object.
|
||||
func (m *Mirror) AfterLoad(session *xorm.Session) {
|
||||
if m == nil {
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
switch colName {
|
||||
case "repo_id":
|
||||
m.Repo, err = GetRepositoryByID(m.RepoID)
|
||||
if err != nil {
|
||||
log.Error(3, "GetRepositoryByID[%d]: %v", m.ID, err)
|
||||
}
|
||||
case "updated_unix":
|
||||
m.Updated = time.Unix(m.UpdatedUnix, 0).Local()
|
||||
case "next_update_unix":
|
||||
m.NextUpdate = time.Unix(m.NextUpdateUnix, 0).Local()
|
||||
m.Repo, err = getRepositoryByID(session, m.RepoID)
|
||||
if err != nil {
|
||||
log.Error(3, "getRepositoryByID[%d]: %v", m.ID, err)
|
||||
}
|
||||
|
||||
m.Updated = time.Unix(m.UpdatedUnix, 0).Local()
|
||||
m.NextUpdate = time.Unix(m.NextUpdateUnix, 0).Local()
|
||||
}
|
||||
|
||||
// ScheduleNextUpdate calculates and sets next update time.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue