fix: populate fsid for legacy NFS exports on migration
Migration 0002 added fsid column with DEFAULT 0 but never populated existing rows. Now PopulateLegacyFSIDs() runs after 0002 to extract fsid from legacy options string or generate random. Also: move generateRandomFSID to internal/system to avoid import cycles. Migration 0004 drops the legacy options column. Version: 0.3.1 -> 0.3.2
This commit is contained in:
@@ -3,8 +3,6 @@ package importer
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -170,14 +168,10 @@ func parseExportLine(line string) (db.NFSExport, bool) {
|
||||
}
|
||||
|
||||
func generateImportFSID() (int64, error) {
|
||||
var b [4]byte
|
||||
if _, err := rand.Read(b[:]); err != nil {
|
||||
n, err := system.GenerateRandomFSID()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
n := binary.BigEndian.Uint32(b[:])
|
||||
if n == 0 {
|
||||
n = 1
|
||||
}
|
||||
return int64(n), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user