mirror of
https://github.com/kopia/kopia.git
synced 2026-01-19 20:07:56 -05:00
This removes big shared lock held for for the duration of each request and replaces it with trivially short lock to capture the current state of the server/repository before passing it to handlers. Handlers are now limited to only accessing a small subset of Server functionality to be able to better reason about them.
28 lines
729 B
Go
28 lines
729 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"path/filepath"
|
|
|
|
"github.com/kopia/kopia/internal/ospath"
|
|
"github.com/kopia/kopia/internal/serverapi"
|
|
"github.com/kopia/kopia/snapshot"
|
|
)
|
|
|
|
func handlePathResolve(ctx context.Context, rc requestContext) (interface{}, *apiError) {
|
|
var req serverapi.ResolvePathRequest
|
|
|
|
if err := json.Unmarshal(rc.body, &req); err != nil {
|
|
return nil, requestError(serverapi.ErrorMalformedRequest, "malformed request body")
|
|
}
|
|
|
|
return &serverapi.ResolvePathResponse{
|
|
SourceInfo: snapshot.SourceInfo{
|
|
Path: filepath.Clean(ospath.ResolveUserFriendlyPath(req.Path, true)),
|
|
Host: rc.rep.ClientOptions().Hostname,
|
|
UserName: rc.rep.ClientOptions().Username,
|
|
},
|
|
}, nil
|
|
}
|