Close zstd encoder before reading file info, to ensure accurate file size reporting for index file
This commit is contained in:
parent
b90f6cfc64
commit
89637c12b2
|
@ -106,11 +106,17 @@ func (index *fileIndex) Export(path string) error {
|
||||||
index.mutex.RLock()
|
index.mutex.RLock()
|
||||||
err = enc.Encode(&index.list)
|
err = enc.Encode(&index.list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
index.mutex.RUnlock()
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
length := len(index.list)
|
length := len(index.list)
|
||||||
index.mutex.RUnlock()
|
index.mutex.RUnlock()
|
||||||
|
|
||||||
|
// Close encoder prior to checking file size,
|
||||||
|
// to ensure the correct value is returned.
|
||||||
|
z.Close()
|
||||||
|
|
||||||
stats, err := file.Stat()
|
stats, err := file.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -154,6 +160,8 @@ func (index *fileIndex) Import(path string) error {
|
||||||
index.mutex.Lock()
|
index.mutex.Lock()
|
||||||
err = dec.Decode(&index.list)
|
err = dec.Decode(&index.list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
index.mutex.Unlock()
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
length := len(index.list)
|
length := len(index.list)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AllowedCharacters string = `^[A-z0-9.\-_]+$`
|
AllowedCharacters string = `^[A-z0-9.\-_]+$`
|
||||||
ReleaseVersion string = "3.7.0"
|
ReleaseVersion string = "3.7.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in New Issue