[client] Apply the file drop mode and destination as one change

FileDropSetSettings committed the mode first, through a Set that persists it
and fires the handler binding the receiver, and only then validated the
destination. A destination the caller may not use returned an error the UI
read as "nothing changed", while the profile had already moved to
auto-accept with the receiver listening, so the next offer from any peer was
taken without a prompt and delivered to the old directory.

Both halves are now settled before either is applied, and applied in the one
Set that already carries them: it validates the mode before touching
anything, so a refusal on either half leaves the policy alone.
This commit is contained in:
Zoltán Papp
2026-09-08 21:18:55 +02:00
parent 329b24da3b
commit ab47d2a4bf
2 changed files with 111 additions and 6 deletions
+9 -6
View File
@@ -267,19 +267,22 @@ func (s *Server) FileDropSetSettings(ctx context.Context, req *proto.FileDropSet
return nil, err
}
// Both halves are settled before either is applied, and then applied in one
// write: committing the mode first left a refused destination behind a
// profile already switched to auto-accept, with the receiver bound, while
// the caller was told the whole request had failed.
policy := mgr.Policy().Get()
policy.Mode = filedrop.Mode(req.GetMode())
if err := mgr.Policy().Set(policy); err != nil {
return nil, err
}
if dir := req.GetDestinationDir(); dir != mgr.DestinationDir() {
if err := s.validateFileDropDestination(ctx, dir); err != nil {
return nil, err
}
if err := mgr.SetDestinationDir(dir); err != nil {
return nil, err
}
policy.DestinationDir = dir
}
if err := mgr.Policy().Set(policy); err != nil {
return nil, err
}
return &proto.FileDropSetSettingsResponse{}, nil
}