mirror of
https://github.com/status-im/status-go.git
synced 2025-01-12 23:55:03 +00:00
fix(history-archive): Skip dowloading data from torrent if free space is not enought (#4449)
This commit is contained in:
parent
42cf9fa740
commit
af9d3bc7b3
@ -43,3 +43,4 @@ var ErrCannotBanOwnerOrAdmin = errors.New("not allowed to ban admin or owner")
|
|||||||
var ErrInvalidManageTokensPermission = errors.New("no privileges to manage tokens")
|
var ErrInvalidManageTokensPermission = errors.New("no privileges to manage tokens")
|
||||||
var ErrRevealedAccountsAbsent = errors.New("revealed accounts is absent")
|
var ErrRevealedAccountsAbsent = errors.New("revealed accounts is absent")
|
||||||
var ErrNoRevealedAccountsSignature = errors.New("revealed accounts without the signature")
|
var ErrNoRevealedAccountsSignature = errors.New("revealed accounts without the signature")
|
||||||
|
var ErrNoFreeSpaceForHistoryArchives = errors.New("history archive: No free space for downloading history archives")
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/anacrolix/torrent"
|
"github.com/anacrolix/torrent"
|
||||||
@ -3972,6 +3973,22 @@ func (m *Manager) SeedHistoryArchiveTorrent(communityID types.HexBytes) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var stat syscall.Statfs_t
|
||||||
|
wd, _ := os.Getwd()
|
||||||
|
|
||||||
|
err = syscall.Statfs(wd, &stat)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Available blocks * size per block = available space in bytes
|
||||||
|
freeSpace := stat.Bavail * uint64(stat.Bsize)
|
||||||
|
|
||||||
|
if freeSpace <= uint64(torrent.Length()) {
|
||||||
|
return ErrNoFreeSpaceForHistoryArchives
|
||||||
|
}
|
||||||
|
|
||||||
torrent.DownloadAll()
|
torrent.DownloadAll()
|
||||||
|
|
||||||
m.publish(&Subscription{
|
m.publish(&Subscription{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user