Files
kopia/internal/server/api_paths.go
Jarek Kowalski 9cba4a97be refactor(repository): major server code refactoring (#1837)
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.
2022-03-19 22:01:38 -07:00

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
}