newHandler creates a new handler for the protocol.
(cfg *config.Configuration, output *os.File, msg *inputMessage)
| 172 | |
| 173 | // newHandler creates a new handler for the protocol. |
| 174 | func newHandler(cfg *config.Configuration, output *os.File, msg *inputMessage) (*fileHandler, error) { |
| 175 | url, err := fileUrlFromRemote(cfg, msg.Remote, msg.Operation) |
| 176 | if err != nil { |
| 177 | return nil, err |
| 178 | } |
| 179 | if url == nil { |
| 180 | return nil, errors.New(tr.Tr.Get("no valid file:// URLs found")) |
| 181 | } |
| 182 | |
| 183 | path, err := tools.TranslateCygwinPath(fixUrlPath(url.Path)) |
| 184 | if err != nil { |
| 185 | return nil, err |
| 186 | } |
| 187 | |
| 188 | gitdir, err := gitDirAtPath(path) |
| 189 | if err != nil { |
| 190 | return nil, err |
| 191 | } |
| 192 | |
| 193 | tempdir, err := os.MkdirTemp(cfg.TempDir(), "lfs-standalone-file-*") |
| 194 | if err != nil { |
| 195 | return nil, err |
| 196 | } |
| 197 | |
| 198 | tracerx.Printf("using %q as remote git directory", gitdir) |
| 199 | |
| 200 | return &fileHandler{ |
| 201 | remotePath: path, |
| 202 | remoteConfig: config.NewIn(gitdir, gitdir), |
| 203 | output: output, |
| 204 | config: cfg, |
| 205 | tempdir: tempdir, |
| 206 | }, nil |
| 207 | } |
| 208 | |
| 209 | // dispatch dispatches the event depending on the message type. |
| 210 | func (h *fileHandler) dispatch(msg *inputMessage) bool { |
no test coverage detected