Skip to content

Commit 3905140

Browse files
authored
Release v2.1.0 (#726)
* increment app version (#721) * fix disk space check for windows (#722)
1 parent 0a27bd7 commit 3905140

6 files changed

Lines changed: 76 additions & 24 deletions

File tree

libwallet/utils/config.go

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"regexp"
1111
"runtime"
1212
"strings"
13-
"syscall"
1413
"time"
1514

1615
"gioui.org/app"
@@ -194,31 +193,28 @@ func GetFreeDiskSpace() (uint64, error) {
194193
var path string
195194
var err error
196195
switch runtime.GOOS {
197-
case "android", "ios":
198-
path, err = app.DataDir()
199-
if err != nil {
200-
return 0, err
196+
case "android", "ios", "linux", "darwin", "windows":
197+
if runtime.GOOS == "android" || runtime.GOOS == "ios" {
198+
path, err = app.DataDir()
199+
if err != nil {
200+
return 0, err
201+
}
202+
} else {
203+
path, err = os.UserHomeDir()
204+
if err != nil {
205+
return 0, err
206+
}
201207
}
202-
case "linux", "darwin", "windows":
203-
path, err = os.UserHomeDir()
208+
209+
freeSpace, err := DiskSpace(path)
204210
if err != nil {
205211
return 0, err
206212
}
207-
default:
208-
return 0, nil
209-
}
210213

211-
var stat syscall.Statfs_t
214+
return freeSpace, nil
212215

213-
// Get file system statistics for the specified path
214-
err = syscall.Statfs(path, &stat)
215-
if err != nil {
216-
return 0, err
216+
default:
217+
return 0, nil
217218
}
218219

219-
// Calculate available space: free blocks * block size
220-
freeBytes := stat.Bavail * uint64(stat.Bsize)
221-
222-
// Convert bytes to MB
223-
return freeBytes / (1024 * 1024), nil
224220
}

libwallet/utils/disk_general.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//go:build linux || android || ios || darwin
2+
// +build linux android ios darwin
3+
4+
package utils
5+
6+
import (
7+
"syscall"
8+
)
9+
10+
// DiskSpace returns the available disk space in MB for the specified path
11+
func DiskSpace(path string) (uint64, error) {
12+
13+
var stat syscall.Statfs_t
14+
15+
// Get file system statistics for the specified path
16+
err := syscall.Statfs(path, &stat)
17+
if err != nil {
18+
return 0, err
19+
}
20+
21+
// Calculate available space: free blocks * block size
22+
freeBytes := stat.Bavail * uint64(stat.Bsize)
23+
24+
// Convert bytes to MB
25+
return freeBytes / (1024 * 1024), nil
26+
}

libwallet/utils/disk_windows.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//go:build windows
2+
// +build windows
3+
4+
package utils
5+
6+
import (
7+
"golang.org/x/sys/windows"
8+
)
9+
10+
// DiskSpace returns the total and free disk space in bytes for the specified directory
11+
func DiskSpace(dir string) (free uint64, err error) {
12+
var (
13+
directoryName = windows.StringToUTF16Ptr(dir)
14+
freeBytesAvailableToCaller uint64
15+
totalNumberOfBytes uint64
16+
totalNumberOfFreeBytes uint64
17+
)
18+
err = windows.GetDiskFreeSpaceEx(
19+
directoryName,
20+
&freeBytesAvailableToCaller,
21+
&totalNumberOfBytes,
22+
&totalNumberOfFreeBytes,
23+
)
24+
if err != nil {
25+
return 0, err
26+
}
27+
28+
// Convert bytes to MB
29+
return totalNumberOfFreeBytes / (1024 * 1024), nil
30+
}

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626

2727
var (
2828
// Version is the application version. It is set using the -ldflags
29-
Version = "2.0.2"
29+
Version = "2.1.0"
3030
// BuildDate is the date the application was built. It is set using the -ldflags
3131
BuildDate string
3232
// BuildEnv is the build environment. It is set using the -ldflags

reproduciblebuilds/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This how we want to name the binary output
22
BUILDNAME=cryptopower
33

4-
VERSION="v2.0.2"
4+
VERSION="v2.1.0"
55
# dev or prod
66
BuildEnv="prod"
77

version/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const (
2525
const (
2626
AppName string = "cryptopower"
2727
AppMajor uint = 2
28-
AppMinor uint = 0
29-
AppPatch uint = 2
28+
AppMinor uint = 1
29+
AppPatch uint = 0
3030
)
3131

3232
// go build -v -ldflags "-X github.com/crypto-power/cryptopower/version.appPreRelease= -X github.com/crypto-power/cryptopower/version.appBuild=`git rev-parse --short HEAD`"

0 commit comments

Comments
 (0)