Skip to content

Commit 3e16f7d

Browse files
Copilotsawka
andcommitted
Refine RemoteFileMultiInfo error handling and dedup behavior
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
1 parent 40674e3 commit 3e16f7d

4 files changed

Lines changed: 16 additions & 52 deletions

File tree

frontend/types/gotypes.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ declare global {
882882
path: string;
883883
dir?: string;
884884
name?: string;
885+
staterror?: string;
885886
notfound?: boolean;
886887
opts?: FileOpts;
887888
size?: number;

pkg/wshrpc/wshremote/wshremote_file.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,26 @@ func (impl *ServerImpl) RemoteFileMultiInfoCommand(ctx context.Context, data wsh
524524
cwd = filepath.Clean(wavebase.ExpandHomeDirSafe(cwd))
525525
rtn := make(map[string]wshrpc.FileInfo, len(data.Paths))
526526
for _, path := range data.Paths {
527+
if _, found := rtn[path]; found {
528+
continue
529+
}
530+
if ctx.Err() != nil {
531+
return nil, ctx.Err()
532+
}
527533
cleanedPath := wavebase.ExpandHomeDirSafe(path)
528534
if !filepath.IsAbs(cleanedPath) {
529535
cleanedPath = filepath.Join(cwd, cleanedPath)
530536
}
531537
fileInfo, err := impl.fileInfoInternal(cleanedPath, false)
532538
if err != nil {
533-
return nil, err
539+
rtn[path] = wshrpc.FileInfo{
540+
Path: wavebase.ReplaceHomeDir(cleanedPath),
541+
Dir: computeDirPart(cleanedPath),
542+
Name: filepath.Base(cleanedPath),
543+
StatError: err.Error(),
544+
SupportsMkdir: true,
545+
}
546+
continue
534547
}
535548
rtn[path] = *fileInfo
536549
}

pkg/wshrpc/wshremote/wshremote_file_test.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

pkg/wshrpc/wshrpctypes_file.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type FileInfo struct {
5757
Path string `json:"path"` // cleaned path (may have "~")
5858
Dir string `json:"dir,omitempty"` // returns the directory part of the path (if this is a a directory, it will be equal to Path). "~" will be expanded, and separators will be normalized to "/"
5959
Name string `json:"name,omitempty"`
60+
StatError string `json:"staterror,omitempty"`
6061
NotFound bool `json:"notfound,omitempty"`
6162
Opts *FileOpts `json:"opts,omitempty"`
6263
Size int64 `json:"size,omitempty"`

0 commit comments

Comments
 (0)