(ctx context.Context, name string)
| 705 | } |
| 706 | |
| 707 | func (mm *mountManager) Deactivate(ctx context.Context, name string) error { |
| 708 | namespace, err := namespaces.NamespaceRequired(ctx) |
| 709 | if err != nil { |
| 710 | return err |
| 711 | } |
| 712 | |
| 713 | var ( |
| 714 | mid uint64 |
| 715 | allActive []mount.ActiveMount |
| 716 | ) |
| 717 | |
| 718 | // First in a single transaction, mark the mounts as deactivated |
| 719 | if err := mm.db.Update(func(tx *bolt.Tx) error { |
| 720 | v1bkt := tx.Bucket([]byte("v1")) |
| 721 | if v1bkt == nil { |
| 722 | return fmt.Errorf("missing v1 bucket: %w", errdefs.ErrNotFound) |
| 723 | } |
| 724 | |
| 725 | nsbkt := v1bkt.Bucket([]byte(namespace)) |
| 726 | if nsbkt == nil { |
| 727 | return fmt.Errorf("missing namespace %q bucket: %w", namespace, errdefs.ErrNotFound) |
| 728 | } |
| 729 | |
| 730 | mbkt := nsbkt.Bucket(bucketKeyMounts) |
| 731 | if mbkt == nil { |
| 732 | return fmt.Errorf("missing mounts bucket: %w", errdefs.ErrNotFound) |
| 733 | } |
| 734 | bkt := mbkt.Bucket([]byte(name)) |
| 735 | if bkt == nil { |
| 736 | return fmt.Errorf("missing mount %q bucket: %w", name, errdefs.ErrNotFound) |
| 737 | } |
| 738 | |
| 739 | mid = readID(bkt) |
| 740 | |
| 741 | lid := bkt.Get(bucketKeyLease) |
| 742 | if lid != nil { |
| 743 | lssbkt := nsbkt.Bucket(bucketKeyLeases) |
| 744 | if lssbkt != nil { |
| 745 | lsbkt := lssbkt.Bucket(lid) |
| 746 | if lsbkt != nil { |
| 747 | if err = lsbkt.Delete([]byte(name)); err != nil { |
| 748 | return err |
| 749 | } |
| 750 | } |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | abkt := bkt.Bucket(bucketKeyActive) |
| 755 | if abkt != nil { |
| 756 | abkt.ForEachBucket(func(k []byte) error { |
| 757 | active, err := readActiveMount(abkt.Bucket(k)) |
| 758 | if err != nil { |
| 759 | return err |
| 760 | } |
| 761 | allActive = append(allActive, active) |
| 762 | return nil |
| 763 | }) |
| 764 | } |
nothing calls this directly
no test coverage detected