Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-ds-flatfs
Commits
24e5fbe6
Commit
24e5fbe6
authored
Apr 02, 2018
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only display "Calculating ..." msg if calculation takes more then 5 sec.
parent
903d4a77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
flatfs.go
flatfs.go
+12
-2
No files found.
flatfs.go
View file @
24e5fbe6
...
...
@@ -27,8 +27,9 @@ var log = logging.Logger("flatfs")
const (
extension = ".data"
diskUsageMessageTimeout = 5 * time.Second
diskUsageCheckpointPercent = 1.0
diskUsageCheckpointTimeout = 2
.0
* time.Second
diskUsageCheckpointTimeout = 2 * time.Second
)
var (
...
...
@@ -761,12 +762,21 @@ func (fs *Datastore) calculateDiskUsage() error {
return nil
}
fmt.Printf("Calculating datastore size. This might take %s at most and will happen only once\n", DiskUsageCalcTimeout.String())
msgDone := make(chan struct{}, 1) // prevent race condition
msgTimer := time.AfterFunc(diskUsageMessageTimeout, func() {
fmt.Printf("Calculating datastore size. This might take %s at most and will happen only once\n",
DiskUsageCalcTimeout.String())
msgDone <- struct{}{}
})
defer msgTimer.Stop()
deadline := time.Now().Add(DiskUsageCalcTimeout)
du, accuracy, err := folderSize(fs.path, deadline)
if err != nil {
return err
}
if !msgTimer.Stop() {
<-msgDone
}
if accuracy == timedoutA {
fmt.Println("WARN: It took to long to calculate the datastore size")
fmt.Printf("WARN: The total size (%d) is an estimation. You can fix errors by\n", du)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment