Address JetBrains warnings

This commit is contained in:
2025-12-26 19:12:48 -05:00
parent b591e2ef5a
commit 2880ce2823
10 changed files with 34 additions and 44 deletions
+6 -8
View File
@@ -14,8 +14,8 @@ import (
"github.com/rwinkhart/libmutton/synccommon"
)
// AgeEntry creates updates the age file for a vanity path.
func AgeEntry(vanityPath string, timestamp int64) error {
// Entry creates updates the age file for a vanity path.
func Entry(vanityPath string, timestamp int64) error {
ageFilePath := global.AgeDir + global.PathSeparator + strings.ReplaceAll(vanityPath, "/", global.FSPath)
f, err := os.OpenFile(ageFilePath, os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
@@ -29,10 +29,10 @@ func AgeEntry(vanityPath string, timestamp int64) error {
return nil
}
// AgeAllPasswordEntries adds age data for all un-aged entries containing passwords.
// AllPasswordEntries adds age data for all un-aged entries containing passwords.
// Each entry is aged with a random timestamp from within the last year to prevent
// all entries having their passwords expire at the same time.
func AgeAllPasswordEntries(forceReage bool) error {
func AllPasswordEntries(forceReage bool) error {
allVanityPaths, _, err := synccommon.WalkEntryDir()
if err != nil {
return errors.New("unable to walk entry directory: " + err.Error())
@@ -57,7 +57,7 @@ func AgeAllPasswordEntries(forceReage bool) error {
// calculate random UNIX timestamp from within the last 365 days
offsetInt, _ := rand.Int(rand.Reader, big.NewInt(31557600))
randomOffset := time.Duration(offsetInt.Int64()) * time.Second
err = AgeEntry(vanityPath, time.Now().Add(-randomOffset).Unix())
err = Entry(vanityPath, time.Now().Add(-randomOffset).Unix())
if err != nil {
return err
}
@@ -76,13 +76,11 @@ func TranslateAgeTimestamp(timestamp int64) uint8 {
if timestamp == 0 {
return 0
}
daysOld := time.Since(time.Unix(timestamp, 0)).Hours() / 24
if daysOld >= 365 {
return 3 // expired
} else if daysOld >= 335 {
return 2 // expiring soon
} else {
return 1 // fresh
}
return 1 // fresh
}