Skip to content

Commit

Permalink
more mount sync improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Dec 2, 2019
1 parent 1984024 commit d7a00b4
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions mount/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,35 +193,17 @@ func (d *Datastore) Put(key ds.Key, value []byte) error {
func (d *Datastore) Sync(prefix ds.Key) error {
// Sync all mount points below the prefix
// Sync the mount point right at (or above) the prefix
// Return ErrNoMount if no mount points are synced
atLeastOneSync := false
for _, m := range d.mounts {
if m.Prefix.Equal(prefix) {
if err := m.Datastore.Sync(ds.NewKey("/")); err != nil {
return err
}
return nil
}
if m.Prefix.IsAncestorOf(prefix) {
s := strings.TrimPrefix(prefix.String(), m.Prefix.String())
k := ds.NewKey(s)
if err := m.Datastore.Sync(k); err != nil {
return err
}
return nil
dstores, mountPts, rest := d.lookupAll(prefix)
for i, suffix := range rest {
if err := dstores[i].Sync(suffix); err != nil {
return err
}

if m.Prefix.IsDescendantOf(prefix) {
if err := m.Datastore.Sync(ds.NewKey("/")); err != nil {
return err
}
atLeastOneSync = true
if mountPts[i].Equal(prefix) || suffix.String() != "/" {
return nil
}
}

if !atLeastOneSync {
return ErrNoMount
}
return nil
}

Expand Down

0 comments on commit d7a00b4

Please sign in to comment.