@@ -9,14 +9,14 @@ import (
9
9
"os"
10
10
"path/filepath"
11
11
"strings"
12
- "syscall"
13
12
"time"
14
13
15
14
"github.com/btcsuite/btcd/btcutil"
16
15
"github.com/btcsuite/btclog/v2"
17
16
"github.com/jessevdk/go-flags"
18
17
"github.com/lightninglabs/lndinit/migratekvdb"
19
18
"github.com/lightningnetwork/lnd/channeldb"
19
+ "github.com/lightningnetwork/lnd/healthcheck"
20
20
"github.com/lightningnetwork/lnd/kvdb"
21
21
"github.com/lightningnetwork/lnd/kvdb/postgres"
22
22
"github.com/lightningnetwork/lnd/kvdb/sqlbase"
@@ -590,7 +590,7 @@ func openSourceDb(cfg *SourceDB, prefix, network string,
590
590
// Because the destination can also just be a postgres dsn, we just
591
591
// check if the source dir has enough free space to hold a copy of the
592
592
// db.
593
- freeSpace , err := availableDiskSpace (cfg .Bolt .DataDir )
593
+ freeSpace , err := healthcheck . AvailableDiskSpace (cfg .Bolt .DataDir )
594
594
if err != nil {
595
595
return nil , fmt .Errorf ("error determining source directory " +
596
596
"free space: %v" , err )
@@ -922,20 +922,6 @@ func createMigrationCompletedFile(sourceDB *SourceDB, prefix,
922
922
return nil
923
923
}
924
924
925
- // availableDiskSpace returns the available disk space in bytes of the given
926
- // file system.
927
- func availableDiskSpace (path string ) (uint64 , error ) {
928
- s := syscall.Statfs_t {}
929
- err := syscall .Statfs (path , & s )
930
- if err != nil {
931
- return 0 , err
932
- }
933
-
934
- // Some OSes have s.Bavail defined as int64, others as uint64, so we
935
- // need the explicit type conversion here.
936
- return uint64 (s .Bavail ) * uint64 (s .Bsize ), nil // nolint:unconvert
937
- }
938
-
939
925
// checkPathExists verifies that the directory exists.
940
926
func checkPathExists (path string ) error {
941
927
dir := filepath .Dir (path )
0 commit comments