mirror of
https://github.com/kopia/kopia.git
synced 2026-01-02 19:47:51 -05:00
* content: fixed time-based auto-flush behavior to behave like Flush() Previously it would sometimes be possible for a content whose write started before time-based flush to finish writing afterwards (and it would be included in the new index). Refactored the code so that time-based flush happens before WriteContent write and behaves exactly the same was as real Flush() so all writes started before it will be awaited during the flush. Also previous regression test was incorrect since it was mocking the wrong blob method. * content: refactored index blob manager crypto to separate file This will be reused for encrypting session info. * content: added support for session markers Session marker (`s` blob) is written BEFORE the first data blob (`p` or `q`) that belongs to new index segment (`n` is written). Session marker is removed AFTER the index blob (`n`) has been written. All pack and index blobs belonging to a session will have the session ID as its suffix, so that if a reader can see `s<sessionID>` blob, they will ignore any `p` and `q` blobs with the same suffix. * maintenance: ignore blobs belonging to active sessions when running blob garbage collection * cli: added 'sessions list' for listing active sessions * content: added retrying writing previously failed blobs before writing new one
29 lines
630 B
Go
29 lines
630 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/repo"
|
|
)
|
|
|
|
var sessionListCommand = sessionCommands.Command("list", "List sessions").Alias("ls")
|
|
|
|
func runSessionList(ctx context.Context, rep *repo.DirectRepository) error {
|
|
sessions, err := rep.ListActiveSessions(ctx)
|
|
if err != nil {
|
|
return errors.Wrap(err, "error listing sessions")
|
|
}
|
|
|
|
for _, s := range sessions {
|
|
printStdout("%v %v@%v %v %v\n", s.ID, s.User, s.Host, formatTimestamp(s.StartTime), formatTimestamp(s.CheckpointTime))
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
sessionListCommand.Action(directRepositoryAction(runSessionList))
|
|
}
|