mirror of https://github.com/Xhofe/alist
				
				
				
			fix: use `utils.Log` in some places
							parent
							
								
									615e5dd118
								
							
						
					
					
						commit
						a6b9dbfbe4
					
				| 
						 | 
					@ -1,12 +1,11 @@
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
 | 
					Copyright © 2022 NAME HERE <EMAIL ADDRESS>
 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
package cmd
 | 
					package cmd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"github.com/alist-org/alist/v3/internal/db"
 | 
						"github.com/alist-org/alist/v3/internal/db"
 | 
				
			||||||
	log "github.com/sirupsen/logrus"
 | 
						"github.com/alist-org/alist/v3/pkg/utils"
 | 
				
			||||||
	"github.com/spf13/cobra"
 | 
						"github.com/spf13/cobra"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,11 +17,11 @@ var cancel2FACmd = &cobra.Command{
 | 
				
			||||||
		Init()
 | 
							Init()
 | 
				
			||||||
		admin, err := db.GetAdmin()
 | 
							admin, err := db.GetAdmin()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			log.Errorf("failed to get admin user: %+v", err)
 | 
								utils.Log.Errorf("failed to get admin user: %+v", err)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			err := db.Cancel2FAByUser(admin)
 | 
								err := db.Cancel2FAByUser(admin)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				log.Errorf("failed to cancel 2FA: %+v", err)
 | 
									utils.Log.Errorf("failed to cancel 2FA: %+v", err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,10 +9,8 @@ import (
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/alist-org/alist/v3/internal/bootstrap/data"
 | 
					 | 
				
			||||||
	log "github.com/sirupsen/logrus"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	_ "github.com/alist-org/alist/v3/drivers"
 | 
						_ "github.com/alist-org/alist/v3/drivers"
 | 
				
			||||||
 | 
						"github.com/alist-org/alist/v3/internal/bootstrap/data"
 | 
				
			||||||
	"github.com/alist-org/alist/v3/internal/conf"
 | 
						"github.com/alist-org/alist/v3/internal/conf"
 | 
				
			||||||
	"github.com/alist-org/alist/v3/internal/operations"
 | 
						"github.com/alist-org/alist/v3/internal/operations"
 | 
				
			||||||
	"github.com/alist-org/alist/v3/pkg/utils"
 | 
						"github.com/alist-org/alist/v3/pkg/utils"
 | 
				
			||||||
| 
						 | 
					@ -90,7 +88,7 @@ var langCmd = &cobra.Command{
 | 
				
			||||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
						Run: func(cmd *cobra.Command, args []string) {
 | 
				
			||||||
		err := os.MkdirAll("lang", 0777)
 | 
							err := os.MkdirAll("lang", 0777)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			log.Fatal("failed create folder: %s", err.Error())
 | 
								utils.Log.Fatal("failed create folder: %s", err.Error())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		generateDriversJson()
 | 
							generateDriversJson()
 | 
				
			||||||
		generateSettingsJson()
 | 
							generateSettingsJson()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,12 +1,11 @@
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
 | 
					Copyright © 2022 NAME HERE <EMAIL ADDRESS>
 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
package cmd
 | 
					package cmd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"github.com/alist-org/alist/v3/internal/db"
 | 
						"github.com/alist-org/alist/v3/internal/db"
 | 
				
			||||||
	log "github.com/sirupsen/logrus"
 | 
						"github.com/alist-org/alist/v3/pkg/utils"
 | 
				
			||||||
	"github.com/spf13/cobra"
 | 
						"github.com/spf13/cobra"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,9 +17,9 @@ var passwordCmd = &cobra.Command{
 | 
				
			||||||
		Init()
 | 
							Init()
 | 
				
			||||||
		admin, err := db.GetAdmin()
 | 
							admin, err := db.GetAdmin()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			log.Errorf("failed get admin user: %+v", err)
 | 
								utils.Log.Errorf("failed get admin user: %+v", err)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			log.Infof("admin user's password is: %s", admin.Password)
 | 
								utils.Log.Infof("admin user's password is: %s", admin.Password)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ the address is defined in config file`,
 | 
				
			||||||
				err = srv.ListenAndServe()
 | 
									err = srv.ListenAndServe()
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if err != nil && err != http.ErrServerClosed {
 | 
								if err != nil && err != http.ErrServerClosed {
 | 
				
			||||||
				utils.Log.Errorf("failed to start: %s", err.Error())
 | 
									utils.Log.Fatalf("failed to start: %s", err.Error())
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}()
 | 
							}()
 | 
				
			||||||
		// Wait for interrupt signal to gracefully shutdown the server with
 | 
							// Wait for interrupt signal to gracefully shutdown the server with
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,7 +71,7 @@ func InitialSettings() []model.SettingItem {
 | 
				
			||||||
		{Key: conf.ApiUrl, Value: "", Type: conf.TypeString, Group: model.SITE},
 | 
							{Key: conf.ApiUrl, Value: "", Type: conf.TypeString, Group: model.SITE},
 | 
				
			||||||
		{Key: conf.BasePath, Value: "", Type: conf.TypeString, Group: model.SITE},
 | 
							{Key: conf.BasePath, Value: "", Type: conf.TypeString, Group: model.SITE},
 | 
				
			||||||
		{Key: conf.SiteTitle, Value: "AList", Type: conf.TypeString, Group: model.SITE},
 | 
							{Key: conf.SiteTitle, Value: "AList", Type: conf.TypeString, Group: model.SITE},
 | 
				
			||||||
		{Key: conf.Announcement, Value: "https://github.com/alist-org/alist", Type: conf.TypeString, Group: model.SITE},
 | 
							{Key: conf.Announcement, Value: "### repo\nhttps://github.com/alist-org/alist", Type: conf.TypeText, Group: model.SITE},
 | 
				
			||||||
		{Key: "pagination_type", Value: "all", Type: conf.TypeSelect, Options: "all,pagination,load_more,auto_load_more", Group: model.SITE},
 | 
							{Key: "pagination_type", Value: "all", Type: conf.TypeSelect, Options: "all,pagination,load_more,auto_load_more", Group: model.SITE},
 | 
				
			||||||
		{Key: "default_page_size", Value: "30", Type: conf.TypeNumber, Group: model.SITE},
 | 
							{Key: "default_page_size", Value: "30", Type: conf.TypeNumber, Group: model.SITE},
 | 
				
			||||||
		// style settings
 | 
							// style settings
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,9 +4,9 @@ import (
 | 
				
			||||||
	"github.com/alist-org/alist/v3/cmd/flags"
 | 
						"github.com/alist-org/alist/v3/cmd/flags"
 | 
				
			||||||
	"github.com/alist-org/alist/v3/internal/db"
 | 
						"github.com/alist-org/alist/v3/internal/db"
 | 
				
			||||||
	"github.com/alist-org/alist/v3/internal/model"
 | 
						"github.com/alist-org/alist/v3/internal/model"
 | 
				
			||||||
 | 
						"github.com/alist-org/alist/v3/pkg/utils"
 | 
				
			||||||
	"github.com/alist-org/alist/v3/pkg/utils/random"
 | 
						"github.com/alist-org/alist/v3/pkg/utils/random"
 | 
				
			||||||
	"github.com/pkg/errors"
 | 
						"github.com/pkg/errors"
 | 
				
			||||||
	log "github.com/sirupsen/logrus"
 | 
					 | 
				
			||||||
	"gorm.io/gorm"
 | 
						"gorm.io/gorm"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,7 @@ func initUser() {
 | 
				
			||||||
			if err := db.CreateUser(admin); err != nil {
 | 
								if err := db.CreateUser(admin); err != nil {
 | 
				
			||||||
				panic(err)
 | 
									panic(err)
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				log.Infof("Successfully created the admin user and the initial password is: %s", admin.Password)
 | 
									utils.Log.Infof("Successfully created the admin user and the initial password is: %s", admin.Password)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			panic(err)
 | 
								panic(err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,10 @@
 | 
				
			||||||
package random
 | 
					package random
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"github.com/google/uuid"
 | 
					 | 
				
			||||||
	"math/rand"
 | 
						"math/rand"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/google/uuid"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var Rand *rand.Rand
 | 
					var Rand *rand.Rand
 | 
				
			||||||
| 
						 | 
					@ -19,7 +20,7 @@ func String(n int) string {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func Token() string {
 | 
					func Token() string {
 | 
				
			||||||
	return uuid.NewString() + String(64)
 | 
						return "alist-" + uuid.NewString() + String(64)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func RangeInt64(left, right int64) int64 {
 | 
					func RangeInt64(left, right int64) int64 {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue