Skip to content
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

custom List show zero result #963

Closed
straysh opened this issue Jul 29, 2024 · 0 comments · Fixed by #964
Closed

custom List show zero result #963

straysh opened this issue Jul 29, 2024 · 0 comments · Fixed by #964
Milestone

Comments

@straysh
Copy link

straysh commented Jul 29, 2024

when using rsync to upload/list/download backups, if remote is empty, custom list command get empty, then the final output shows:

   0B   01/01/0001 00:00:00   remote

look into this code pkg/custom/list_custom.go, when strings.TrimRight(out, "\n") got empty string, strings.Split("", "\n") got []string{""} , but we expect it as []string{}.

outLines := strings.Split(strings.TrimRight(out, "\n"), "\n")
backupList := make([]storage.Backup, len(outLines))
for i, line := range outLines {
	if len(line) > 0 {
		if err = json.Unmarshal([]byte(line), &backupList[i]); err != nil {
			return nil, fmt.Errorf("JSON parsing '%s' error: %v ", line, err)
		}
	}
}

and this result to backupList got []storage.Backup{ storage.Backup{} }, which contains only one empty struct item. and lead to the problem above.

straysh pushed a commit to straysh/clickhouse-backup that referenced this issue Jul 29, 2024
@Slach Slach added this to the 2.5.21 milestone Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants