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

Downloader: handle nil-possibilities #13305

Open
AskAlexSharov opened this issue Jan 2, 2025 · 0 comments
Open

Downloader: handle nil-possibilities #13305

AskAlexSharov opened this issue Jan 2, 2025 · 0 comments
Labels
imp2 Medium importance networking

Comments

@AskAlexSharov
Copy link
Collaborator

in next code pattern many things can be nil:

if info, err := d.torrentInfo(ts.DisplayName); err == nil {
	if info.Completed != nil {
		fi, serr := os.Stat(filepath.Join(d.SnapDir(), info.Name))
		if serr != nil || fi.Size() != *info.Length || !fi.ModTime().Equal(*info.Completed) {
			if err := d.db.Update(d.ctx, torrentInfoReset(info.Name, info.Hash, *info.Length)); err != nil {
				if serr != nil {
					log.Error("[snapshots] Failed to reset db entry after stat error", "file", info.Name, "err", err, "stat-err", serr)
				} else {
					log.Error("[snapshots] Failed to reset db entry after stat mismatch", "file", info.Name, "err", err)
				}
			}
		}
	}
}

possible nils: info, fi.

@AskAlexSharov AskAlexSharov added the imp2 Medium importance label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imp2 Medium importance networking
Projects
None yet
Development

No branches or pull requests

2 participants