-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Efficient "repo stat" (DiskUsage) and "--size-only" flag #5010
Conversation
6a47abb
to
bcbc15a
Compare
@hsanjuan the DHT fixes have been merged, you should be unblocked here |
@whyrusleeping is that the case now? |
Now rebased on master. Thanks @Stebalien for bubbling up deps on some other commit. |
core/commands/repo.go
Outdated
return nil | ||
} | ||
|
||
fmt.Fprintf(wtr, "NumObjects:\t%d\n", stat.NumObjects) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is technically a breaking change but I doubt anyone is relying on this order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope not. I can turn it around though and leave NumObjects as first line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just change it. It's marginally better to not change the "API".
core/corerepo/stat.go
Outdated
} | ||
|
||
// RepoSize returns a *Stat object with the RepoSize and StorageMax fields set. | ||
func RepoSize(ctx context.Context, n *core.IpfsNode) (*Stat, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels a bit funky... what about:
type Size struct {
RepoSize uint64
StorageMax uint64
}
type Stat struct {
StorageSize
NumObjects uint64
RepoPath string
Version string
}
And then have RepoSize
return Size
(and, really, these functions should return be returning these by value). This would also avoid sending zero values for the missing fields.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this is better
3e5587e
to
7a2686e
Compare
7a2686e
to
acce688
Compare
@Stebalien I have addressed the comments. However, since the command output only supports a single type, |
acce688
to
cd9a701
Compare
core/commands/repo.go
Outdated
Encoders: cmds.EncoderMap{ | ||
cmds.Text: cmds.MakeEncoder(func(req *cmds.Request, w io.Writer, v interface{}) error { | ||
stat, ok := v.(*corerepo.Stat) | ||
if !ok { | ||
fmt.Println("adios") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
This makes use of the PersistentDatastore DiskUsage method to obtain the Repo's storage usage (GetStorageUsage()). Additionally, the --size-only flag has been added to the "ipfs repo stat" command. This avoids counting the number of objects in the repository and returns faster. License: MIT Signed-off-by: Hector Sanjuan <[email protected]>
License: MIT Signed-off-by: Hector Sanjuan <[email protected]>
License: MIT Signed-off-by: Hector Sanjuan <[email protected]>
License: MIT Signed-off-by: Hector Sanjuan <[email protected]>
@whyrusleeping can we merge this please? |
@hsanjuan once we do the release which should happen any day now. |
This makes use of the PersistentDatastore DiskUsage method to obtain the Repo's storage usage (GetStorageUsage()).
Additionally, the --size-only flag has been added to the "ipfs repo stat" command. This avoids counting the number of objects in the repository and returns faster.
Overseeds #4550
I had to make some gx magic to fix dependencies and be able to use latest go-datastore. go-libp2p-kad-dht depends on it and afaik the changes there cannot be integrated still etc. I'm happy to leave this hanging until this is sorted out. Thus, tagging this as blocked.