Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
placate lint
  • Loading branch information
techknowlogick committed Oct 15, 2021
commit 13c631b3975b266f96f1673f99edae62761e990b
4 changes: 4 additions & 0 deletions models/update_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/hashicorp/go-version"
)

// RemoteVersion stores the remote version from the JSON endpoint
type RemoteVersion struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think store the version into database is unnecessary. Just send http request every check is better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are storing in the database because we don't want to DDOS ourselves when everyone goes to admin dashboard. Even if we get beefy servers, the user dashboard will always be slower because an HTTP check would need to happen. By storing it in the DB we will eventually be able to add a check to send out an email to admins when a new update happens.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On option is storing the remote version into Gitea local cache in memory.

Another option is using database (this PR).

Both are fine to me.

ID int64 `xorm:"pk autoincr"`
Version string `xorm:"VARCHAR(50)"`
Expand Down Expand Up @@ -92,6 +93,7 @@ func UpdateRemoteVersion(version string) (err error) {
return sess.Commit()
}

// GetRemoteVersion returns the current remote version
func GetRemoteVersion() string {
e := db.GetEngine(db.DefaultContext)
v := &RemoteVersion{ID: 1}
Expand All @@ -102,6 +104,8 @@ func GetRemoteVersion() string {
}
return v.Version
}

// GetNeedUpdate returns true if there is an update needed of Gitea
func GetNeedUpdate() bool {
e := db.GetEngine(db.DefaultContext)
v := &RemoteVersion{ID: 1}
Expand Down