MCPcopy
hub / github.com/wavetermdev/waveterm / checkFileSize

Function checkFileSize

cmd/wsh/cmd/wshcmd-file.go:325–345  ·  view source on GitHub ↗
(path string, maxSize int64)

Source from the content-addressed store, hash-verified

323}
324
325func 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
347func fileCpRun(cmd *cobra.Command, args []string) error {
348 src, dst := args[0], args[1]

Callers 2

fileCpRunFunction · 0.70
fileMvRunFunction · 0.70

Calls 2

FileInfoCommandFunction · 0.92
convertNotFoundErrFunction · 0.85

Tested by

no test coverage detected