Skip to content

Commit 9681403

Browse files
authored
Merge pull request #53 from guggero/fix-disk-check-windows
cmd_migrate_db: use lnd package for disk size check
2 parents 054c619 + aac7941 commit 9681403

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

cmd_migrate_db.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
940926
func checkPathExists(path string) error {
941927
dir := filepath.Dir(path)

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const (
3232
AppMinor uint = 1
3333

3434
// AppPatch defines the application patch for this binary.
35-
AppPatch uint = 25
35+
AppPatch uint = 26
3636

3737
// AppPreRelease MUST only contain characters from semanticAlphabet
3838
// per the semantic versioning spec.

0 commit comments

Comments
 (0)