Compare commits

..

No commits in common. "abc0677b2cdbfb9c859c5dd2e281af07e0726375" and "4e410d4db29e7548bd56994b5731ef922b8685f0" have entirely different histories.

3 changed files with 21 additions and 8 deletions

View File

@ -8,11 +8,15 @@ import (
"errors"
"fmt"
"io/fs"
"math/rand/v2"
"os"
"path/filepath"
"math/big"
"regexp"
"runtime"
"slices"
"crypto/rand"
"os"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
@ -458,9 +462,19 @@ func pickFile(list []string) (string, error) {
return "", nil
case fileCount < 1:
return "", ErrNoMediaFound
}
}
return list[rand.IntN(fileCount)], nil
r, err := rand.Int(rand.Reader, big.NewInt(int64(fileCount)))
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 {

View File

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

View File

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