feat(patch): upgrade patch module (#7738)

* feat(patch): upgrade patch module

* chore(patch): add docs

* fix(patch): skip and rewrite invalid last launched version

* fix(patch): turn two functions into patches
This commit is contained in:
KirCute_ECT
2024-12-30 22:48:33 +08:00
committed by GitHub
parent 42243b1517
commit 5994c17b4e
9 changed files with 184 additions and 35 deletions

View File

@ -0,0 +1,26 @@
package v3_24_0
import (
"github.com/alist-org/alist/v3/internal/db"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/utils"
)
// HashPwdForOldVersion encode passwords using SHA256
// First published: 75acbcc perf: sha256 for user's password (close #3552) by Andy Hsu
func HashPwdForOldVersion() {
users, _, err := op.GetUsers(1, -1)
if err != nil {
utils.Log.Fatalf("[hash pwd for old version] failed get users: %v", err)
}
for i := range users {
user := users[i]
if user.PwdHash == "" {
user.SetPassword(user.Password)
user.Password = ""
if err := db.UpdateUser(&user); err != nil {
utils.Log.Fatalf("[hash pwd for old version] failed update user: %v", err)
}
}
}
}