@@ -9,14 +9,14 @@ import (
99 "os"
1010 "path/filepath"
1111 "strings"
12- "syscall"
1312 "time"
1413
1514 "github.com/btcsuite/btcd/btcutil"
1615 "github.com/btcsuite/btclog/v2"
1716 "github.com/jessevdk/go-flags"
1817 "github.com/lightninglabs/lndinit/migratekvdb"
1918 "github.com/lightningnetwork/lnd/channeldb"
19+ "github.com/lightningnetwork/lnd/healthcheck"
2020 "github.com/lightningnetwork/lnd/kvdb"
2121 "github.com/lightningnetwork/lnd/kvdb/postgres"
2222 "github.com/lightningnetwork/lnd/kvdb/sqlbase"
@@ -590,7 +590,7 @@ func openSourceDb(cfg *SourceDB, prefix, network string,
590590 // Because the destination can also just be a postgres dsn, we just
591591 // check if the source dir has enough free space to hold a copy of the
592592 // db.
593- freeSpace , err := availableDiskSpace (cfg .Bolt .DataDir )
593+ freeSpace , err := healthcheck . AvailableDiskSpace (cfg .Bolt .DataDir )
594594 if err != nil {
595595 return nil , fmt .Errorf ("error determining source directory " +
596596 "free space: %v" , err )
@@ -922,20 +922,6 @@ func createMigrationCompletedFile(sourceDB *SourceDB, prefix,
922922 return nil
923923}
924924
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-
939925// checkPathExists verifies that the directory exists.
940926func checkPathExists (path string ) error {
941927 dir := filepath .Dir (path )
0 commit comments