From bdf5f850f4aa2030ca1a9244ace9f02550b1933e Mon Sep 17 00:00:00 2001 From: Peter Nemere Date: Mon, 9 Dec 2024 09:26:16 +1000 Subject: [PATCH] Print more disk space stats, and ensure download of archived files has a / at the path end --- api/dataimport/datasetArchive/download.go | 4 ++++ core/utils/diskfree_nonwindows.go | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/api/dataimport/datasetArchive/download.go b/api/dataimport/datasetArchive/download.go index 122da83f..1a237f51 100644 --- a/api/dataimport/datasetArchive/download.go +++ b/api/dataimport/datasetArchive/download.go @@ -125,6 +125,10 @@ func (dl *DatasetArchiveDownloader) downloadArchivedZipsForDataset(datasetID str // Download all zip files that have the dataset ID prefixed in their file name // Unzip them in timestamp order into downloadPath archiveSearchPath := path.Join(filepaths.RootArchive, datasetID) + if !strings.HasSuffix(archiveSearchPath, "/") { + archiveSearchPath = archiveSearchPath + "/" + } + dl.log.Infof("Searching for archived files in: s3://%v/%v", dl.datasetBucket, archiveSearchPath) archivedFiles, err := dl.remoteFS.ListObjects(dl.datasetBucket, archiveSearchPath) diff --git a/core/utils/diskfree_nonwindows.go b/core/utils/diskfree_nonwindows.go index 7a16aabe..830b4dd2 100644 --- a/core/utils/diskfree_nonwindows.go +++ b/core/utils/diskfree_nonwindows.go @@ -3,6 +3,7 @@ package utils import ( + "fmt" "os" "golang.org/x/sys/unix" @@ -15,7 +16,27 @@ func GetDiskAvailableBytes() (uint64, error) { return 0, err } - unix.Statfs(wd, &stat) + err = unix.Statfs(wd, &stat) + if err != nil { + return 0, err + } + + fmt.Sprintf("Bavail: %v", stat.Bavail) + fmt.Sprintf("Bfree: %v", stat.Bfree) + fmt.Sprintf("Blocks: %v", stat.Blocks) + fmt.Sprintf("Bsize: %v", stat.Bsize) + fmt.Sprintf("Ffree: %v", stat.Ffree) + fmt.Sprintf("Files: %v", stat.Files) + fmt.Sprintf("Flags: %v", stat.Flags) + fmt.Sprintf("Flags_ext: %v", stat.Flags_ext) + fmt.Sprintf("Fsid: %v", stat.Fsid.Val) + fmt.Sprintf("Fssubtype: %v", stat.Fssubtype) + fmt.Sprintf("Fstypename: %v", stat.Fstypename) + fmt.Sprintf("Iosize: %v", stat.Iosize) + fmt.Sprintf("Mntfromname: %v", stat.Mntfromname) + fmt.Sprintf("Mntonname: %v", stat.Mntonname) + fmt.Sprintf("Owner: %v", stat.Owner) + fmt.Sprintf("Type: %v", stat.Type) // Available blocks * size per block = available space in bytes return stat.Bavail * uint64(stat.Bsize), nil