ipfs / go-ds-flatfs

A datastore implementation using sharded directories and flat files to store data
MIT License
46 stars 21 forks source link

Don't display calculating datastore size on empty repo. #37

Closed kevina closed 6 years ago

kevina commented 6 years ago

We should detect when a repo was just created (or empty) and avoid displaying this message:

Calculating datastore size. This might take 5m0s at most and will happen only once
Stebalien commented 6 years ago

We can do this with a timeout. That is, fire off a goroutine:

done := make(chan struct{})
cancel := make(chan struct{})

go func() {
    defer close(done)
    select {
    case <-time.After(...):
        fmt.Println(...)
    case <-cancel:
    }
}
// calculate disk usage.
close(cancel)
<-done

This way, we only spam the user when it takes more than, e.g., a second.

kevina commented 6 years ago

We could do that, detecting a new repo is fairly easy though. Just check for the absence of any directories.

Kubuxu commented 6 years ago

It doesn't have to be a "new" repo. If the process takes, for example, less than 5 seconds there is no reason to bother the user.

Kubuxu commented 6 years ago

@kevina can you handle this?

kevina commented 6 years ago

Sorry @Kubuxu I missed your message.

In any case this is now done in #35