Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit b8dfb77

Browse files
committed
fix(plugins/plugin-bash-like): ls on s3 vfs directory can fail
Fixes #6316
1 parent f124b1d commit b8dfb77

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

plugins/plugin-bash-like/fs/src/lib/ls.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
TableStyle
2828
} from '@kui-shell/core'
2929

30-
import { FStat, GlobStats } from '..'
30+
import { GlobStats } from '..'
3131
import { localFilepath } from './usage-helpers'
3232

3333
const dateFormatter = speedDate('MMM DD HH:mm')
@@ -161,14 +161,17 @@ function attrs(
161161
const perms = wide && hasPermissions ? [{ value: formatPermissions(entry), outerCSS: outerCSSSecondary }] : []
162162
const uid = wide && hasUid ? [{ value: formatUid(entry), outerCSS: outerCSSSecondary, css: cssSecondary }] : []
163163
const gid = wide && hasGid ? [{ value: formatGid(entry), outerCSS: outerCSSSecondary, css: cssSecondary }] : []
164-
const size = wide && hasSize ? [{ value: prettyBytes(entry.stats.size).replace(/\s/g, ''), outerCSS: '' }] : []
164+
const size =
165+
wide && hasSize
166+
? [{ value: prettyBytes(entry.stats.size).replace(/\s/g, ''), outerCSS: '', css: 'yellow-text' }]
167+
: []
165168
const lastMod =
166169
wide && hasMtime
167170
? [
168171
{
169172
value: prettyTime(entry.stats.mtimeMs),
170173
outerCSS: outerCSSLesser,
171-
css: `${cssLesser} ${cssSecondary} pre-wrap`
174+
css: `${cssLesser} ${cssSecondary} pre-wrap sub-text`
172175
}
173176
]
174177
: []
@@ -254,9 +257,7 @@ const doLs = (cmd: string) => async (opts: Arguments<LsOptions>): Promise<MixedR
254257
const entries = (await opts.REPL.rexec<GlobStats[]>(cmdline)).content
255258

256259
if (entries.length === 0) {
257-
const isDirs = await Promise.all(
258-
srcs.map(_ => opts.REPL.rexec<FStat>(`vfs fstat ${encodeComponent(_)}`).then(_ => _.content.isDirectory))
259-
)
260+
const isDirs = entries.map(_ => _.dirent.isDirectory)
260261
if (isDirs.some(_ => !_)) {
261262
// ls on at least one non-directory yielded no entries (converseley: it is not an error if an ls on only-directories yielded no entries)
262263
const error: CodedError = new Error(

plugins/plugin-s3/src/vfs/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class S3VFSResponder extends S3VFS implements VFS {
114114
// ls /s3/myBuck*
115115
const buckets = await this.listBucketsMatching(filepath)
116116
return flatten(
117-
await Promise.all(buckets.map(bucketEntry => this.listObjectsMatching(bucketEntry.name, prefix, pattern, true)))
117+
await Promise.all(buckets.map(bucketEntry => this.listObjectsMatching(bucketEntry.name, prefix, pattern)))
118118
)
119119
} else {
120120
// ls /s3/myBucket/myObj*

0 commit comments

Comments
 (0)