Compare commits

...

2 Commits

Author SHA1 Message Date
Seednode abc0677b2c Replace crypto/rand with math/rand/v2 to test 2024-02-08 16:37:49 -06:00
Seednode b17a21b846 Remove ': null' from JSON output 2024-02-08 15:36:07 -06:00
3 changed files with 8 additions and 21 deletions

View File

@ -8,15 +8,11 @@ import (
"errors" "errors"
"fmt" "fmt"
"io/fs" "io/fs"
"math/big" "math/rand/v2"
"regexp"
"runtime"
"slices"
"crypto/rand"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "runtime"
"slices"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -464,17 +460,7 @@ func pickFile(list []string) (string, error) {
return "", ErrNoMediaFound return "", ErrNoMediaFound
} }
r, err := rand.Int(rand.Reader, big.NewInt(int64(fileCount))) return list[rand.IntN(fileCount)], nil
if err != nil {
return "", err
}
val, err := strconv.Atoi(strconv.FormatInt(r.Int64(), 10))
if err != nil {
return "", err
}
return list[val], nil
} }
func preparePath(prefix, path string) string { func preparePath(prefix, path string) string {

View File

@ -5,6 +5,7 @@ Copyright © 2024 Seednode <seednode@seedno.de>
package cmd package cmd
import ( import (
"bytes"
"encoding/gob" "encoding/gob"
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -57,7 +58,7 @@ func makeTree(list []string) ([]byte, error) {
return []byte{}, err return []byte{}, err
} }
return resp, nil return bytes.ReplaceAll(resp, []byte(": null"), []byte{}), nil
} }
func (index *fileIndex) List() []string { func (index *fileIndex) List() []string {

View File

@ -17,7 +17,7 @@ import (
const ( const (
AllowedCharacters string = `^[A-z0-9.\-_]+$` AllowedCharacters string = `^[A-z0-9.\-_]+$`
ReleaseVersion string = "8.6.0" ReleaseVersion string = "8.7.0"
) )
var ( var (