ipn,tailfs: tie TailFS share configuration to user profile
Previously, the configuration of which folders to share persisted across profile changes. Now, it is tied to the user's profile. Updates tailscale/corp#16827 Signed-off-by: Percy Wegmann <percy@tailscale.com>
This commit is contained in:
committed by
Percy Wegmann
parent
16ae0f65c0
commit
6c160e6321
+12
-18
@@ -309,9 +309,9 @@ type LocalBackend struct {
|
||||
// Last ClientVersion received in MapResponse, guarded by mu.
|
||||
lastClientVersion *tailcfg.ClientVersion
|
||||
|
||||
// notifyTailFSSharesOnce is used to only send one initial notification
|
||||
// with the latest set of TailFS shares.
|
||||
notifyTailFSSharesOnce sync.Once
|
||||
// lastNotifiedTailFSShares keeps track of the last set of shares that we
|
||||
// notified about.
|
||||
lastNotifiedTailFSShares atomic.Pointer[views.SliceView[*tailfs.Share, tailfs.ShareView]]
|
||||
}
|
||||
|
||||
type updateStatus struct {
|
||||
@@ -435,8 +435,12 @@ func NewLocalBackend(logf logger.Logf, logID logid.PublicID, sys *tsd.System, lo
|
||||
// initialize TailFS shares from saved state
|
||||
fs, ok := b.sys.TailFSForRemote.GetOK()
|
||||
if ok {
|
||||
shares, err := b.TailFSGetShares()
|
||||
if err == nil && len(shares) > 0 {
|
||||
currentShares := b.pm.prefs.TailFSShares()
|
||||
if currentShares.Len() > 0 {
|
||||
var shares []*tailfs.Share
|
||||
for i := 0; i < currentShares.Len(); i++ {
|
||||
shares = append(shares, currentShares.At(i).AsStruct())
|
||||
}
|
||||
fs.SetShares(shares)
|
||||
}
|
||||
}
|
||||
@@ -2285,15 +2289,7 @@ func (b *LocalBackend) WatchNotifications(ctx context.Context, mask ipn.NotifyWa
|
||||
ini.NetMap = b.netMap
|
||||
}
|
||||
if mask&ipn.NotifyInitialTailFSShares != 0 && b.tailFSSharingEnabledLocked() {
|
||||
shares, err := b.TailFSGetShares()
|
||||
if err != nil {
|
||||
b.logf("unable to notify initial tailfs shares: %v", err)
|
||||
} else {
|
||||
ini.TailFSShares = make(map[string]*tailfs.Share, len(shares))
|
||||
for _, share := range shares {
|
||||
ini.TailFSShares[share.Name] = share
|
||||
}
|
||||
}
|
||||
ini.TailFSShares = b.pm.prefs.TailFSShares()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4669,10 +4665,8 @@ func (b *LocalBackend) setNetMapLocked(nm *netmap.NetworkMap) {
|
||||
}
|
||||
}
|
||||
|
||||
if b.tailFSSharingEnabledLocked() {
|
||||
b.updateTailFSPeersLocked(nm)
|
||||
b.tailFSNotifyCurrentSharesOnce()
|
||||
}
|
||||
b.updateTailFSPeersLocked(nm)
|
||||
b.tailFSNotifyCurrentSharesLocked()
|
||||
}
|
||||
|
||||
func (b *LocalBackend) updatePeersFromNetmapLocked(nm *netmap.NetworkMap) {
|
||||
|
||||
Reference in New Issue
Block a user