-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: Fix the exception of refreshing the token of Ali Cloud Disk #8288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ import ( | |
| "os" | ||
| "os/user" | ||
| "path" | ||
| "path/filepath" | ||
| "sort" | ||
| "strings" | ||
| "time" | ||
|
|
@@ -288,25 +287,26 @@ func (u *SSHService) LoadLog(ctx *gin.Context, req dto.SearchSSHLog) (*dto.SSHLo | |
| var fileList []sshFileItem | ||
| var data dto.SSHLog | ||
| baseDir := "/var/log" | ||
| if err := filepath.Walk(baseDir, func(pathItem string, info os.FileInfo, err error) error { | ||
| if err != nil { | ||
| return err | ||
| fileItems, err := os.ReadDir(baseDir) | ||
| if err != nil { | ||
| return &data, err | ||
| } | ||
| for _, item := range fileItems { | ||
| if item.IsDir() || (!strings.HasPrefix(item.Name(), "secure") && !strings.HasPrefix(item.Name(), "auth")) { | ||
| continue | ||
| } | ||
| if !info.IsDir() && (strings.HasPrefix(info.Name(), "secure") || strings.HasPrefix(info.Name(), "auth")) { | ||
| if !strings.HasSuffix(info.Name(), ".gz") { | ||
| fileList = append(fileList, sshFileItem{Name: pathItem, Year: info.ModTime().Year()}) | ||
| return nil | ||
| } | ||
| itemFileName := strings.TrimSuffix(pathItem, ".gz") | ||
| if _, err := os.Stat(itemFileName); err != nil && os.IsNotExist(err) { | ||
| if err := handleGunzip(pathItem); err == nil { | ||
| fileList = append(fileList, sshFileItem{Name: itemFileName, Year: info.ModTime().Year()}) | ||
| } | ||
| info, _ := item.Info() | ||
| itemPath := path.Join(baseDir, info.Name()) | ||
| if !strings.HasSuffix(item.Name(), ".gz") { | ||
| fileList = append(fileList, sshFileItem{Name: itemPath, Year: info.ModTime().Year()}) | ||
| continue | ||
| } | ||
| itemFileName := strings.TrimSuffix(itemPath, ".gz") | ||
| if _, err := os.Stat(itemFileName); err != nil && os.IsNotExist(err) { | ||
| if err := handleGunzip(itemPath); err == nil { | ||
| fileList = append(fileList, sshFileItem{Name: itemFileName, Year: info.ModTime().Year()}) | ||
| } | ||
| } | ||
| return nil | ||
| }); err != nil { | ||
| return nil, err | ||
| } | ||
| fileList = sortFileList(fileList) | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes:
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code differences: The method
LoadSystemLogchecks for existence of both.logand.gzfiles with the current date suffix but only returns the content of the.logfile if it exists after uncompression. This might not handle cases where users log in with a previous date which does not have a corresponding.gzfile.Optimization suggestion: Instead of directly returning the contents of the
.logfile, consider handling both.logand.gzfiles within the same method to ensure consistency, especially for logging into any day prior to today's logging period.Additional notes: Ensure that the
global.Dir.LogDiris correctly set up and accessible. Also, make sure there are no typos or unnecessary lines left from earlier version changes.