(path string, maxSize int64)
| 323 | } |
| 324 | |
| 325 | func checkFileSize(path string, maxSize int64) (*wshrpc.FileInfo, error) { |
| 326 | fileData := wshrpc.FileData{ |
| 327 | Info: &wshrpc.FileInfo{ |
| 328 | Path: path}} |
| 329 | |
| 330 | info, err := wshclient.FileInfoCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout}) |
| 331 | err = convertNotFoundErr(err) |
| 332 | if err != nil { |
| 333 | return nil, fmt.Errorf("getting file info: %w", err) |
| 334 | } |
| 335 | if info.NotFound { |
| 336 | return nil, fmt.Errorf("%s: no such file", path) |
| 337 | } |
| 338 | if info.IsDir { |
| 339 | return nil, fmt.Errorf("%s: is a directory", path) |
| 340 | } |
| 341 | if info.Size > maxSize { |
| 342 | return nil, fmt.Errorf("file size (%d bytes) exceeds maximum of %d bytes", info.Size, maxSize) |
| 343 | } |
| 344 | return info, nil |
| 345 | } |
| 346 | |
| 347 | func fileCpRun(cmd *cobra.Command, args []string) error { |
| 348 | src, dst := args[0], args[1] |
no test coverage detected