Skip to content

Commit c37ef4a

Browse files
committed
merge: bring in HttpResourceFetcher changes
2 parents 0b4da9d + 37c3c77 commit c37ef4a

File tree

6 files changed

+21
-58
lines changed

6 files changed

+21
-58
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Resource Explorer: S3 tree view now shows bucket contents correctly, even when restricted to root prefix."
4+
}

packages/core/src/shared/clients/s3Client.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { toStream } from '../utilities/collectionUtils'
1919

2020
export const DEFAULT_MAX_KEYS = 300 // eslint-disable-line @typescript-eslint/naming-convention
2121
export const DEFAULT_DELIMITER = '/' // eslint-disable-line @typescript-eslint/naming-convention
22+
export const defaultPrefix = ''
2223

2324
export type Bucket = InterfaceNoSymbol<DefaultBucket>
2425
export type Folder = InterfaceNoSymbol<DefaultFolder>
@@ -460,7 +461,13 @@ export class DefaultS3Client {
460461
Bucket: bucket.name,
461462
Delimiter: DEFAULT_DELIMITER,
462463
MaxKeys: request.maxResults ?? DEFAULT_MAX_KEYS,
463-
Prefix: request.folderPath,
464+
/**
465+
* Set '' as the default prefix to ensure that the bucket's content will be displayed
466+
* when the user has at least list access to the root of the bucket.
467+
* https://github.com/aws/aws-toolkit-vscode/issues/4643
468+
* @default ''
469+
*/
470+
Prefix: request.folderPath ?? defaultPrefix,
464471
ContinuationToken: request.continuationToken,
465472
})
466473
.promise()

packages/core/src/shared/lsp/lspResolver.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import AdmZip from 'adm-zip'
1212
import { TargetContent, logger, LspResult, LspVersion, Manifest } from './types'
1313
import { getApplicationSupportFolder } from '../vscode/env'
1414
import { createHash } from '../crypto'
15-
import request from '../request'
1615
import { lspSetupStage, StageResolver, tryStageResolvers } from './utils/stage'
16+
import { HttpResourceFetcher } from '../resourcefetcher/httpResourceFetcher'
1717

1818
export class LanguageServerResolver {
1919
constructor(
@@ -194,14 +194,14 @@ export class LanguageServerResolver {
194194

195195
const fetchTasks = contents.map(async (content) => {
196196
return {
197-
res: await request.fetch('GET', content.url).response,
197+
res: await new HttpResourceFetcher(content.url, { showUrl: true }).get(),
198198
hash: content.hashes[0],
199199
filename: content.filename,
200200
}
201201
})
202202
const fetchResults = await Promise.all(fetchTasks)
203203
const verifyTasks = fetchResults.flatMap(async (fetchResult) => {
204-
if (!fetchResult.res.ok || !fetchResult.res.body) {
204+
if (!(fetchResult.res && fetchResult.res.ok && fetchResult.res.body)) {
205205
return []
206206
}
207207

packages/core/src/shared/lsp/manifestResolver.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import { getLogger } from '../logger/logger'
77
import { ToolkitError } from '../errors'
8-
import { RetryableResourceFetcher } from '../resourcefetcher/httpResourceFetcher'
98
import { Timeout } from '../utilities/timeoutUtils'
109
import globals from '../extensionGlobals'
1110
import { Manifest } from './types'
1211
import { StageResolver, tryStageResolvers } from './utils/stage'
12+
import { HttpResourceFetcher } from '../resourcefetcher/httpResourceFetcher'
1313

1414
const logger = getLogger('lsp')
1515

@@ -54,14 +54,11 @@ export class ManifestResolver {
5454
}
5555

5656
private async fetchRemoteManifest(): Promise<Manifest> {
57-
const resourceFetcher = new RetryableResourceFetcher({
58-
resource: this.manifestURL,
59-
params: {
60-
timeout: new Timeout(manifestTimeoutMs),
61-
},
62-
})
57+
const resp = await new HttpResourceFetcher(this.manifestURL, {
58+
showUrl: true,
59+
timeout: new Timeout(manifestTimeoutMs),
60+
}).getNewETagContent(this.getEtag())
6361

64-
const resp = await resourceFetcher.getNewETagContent(this.getEtag())
6562
if (!resp.content) {
6663
throw new ToolkitError('New content was not downloaded; fallback to the locally stored manifest')
6764
}

packages/core/src/shared/resourcefetcher/httpResourceFetcher.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -134,51 +134,6 @@ export class HttpResourceFetcher implements ResourceFetcher<Response> {
134134
}
135135
}
136136

137-
export class RetryableResourceFetcher extends HttpResourceFetcher {
138-
private readonly requestTimeoutMs: number
139-
private readonly retryIntervalMs: number
140-
private readonly resource: string
141-
142-
constructor({
143-
resource,
144-
params: { retryNumber = 5, retryIntervalMs = 3000, showUrl = true, timeout = new Timeout(5000) },
145-
}: {
146-
resource: string
147-
params: {
148-
retryNumber?: number
149-
retryIntervalMs?: number
150-
showUrl?: boolean
151-
timeout?: Timeout
152-
}
153-
}) {
154-
super(resource, {
155-
showUrl,
156-
timeout,
157-
})
158-
this.requestTimeoutMs = retryNumber * retryIntervalMs
159-
this.retryIntervalMs = retryIntervalMs
160-
this.resource = resource
161-
}
162-
163-
fetch(versionTag?: string) {
164-
return waitUntil(
165-
async () => {
166-
try {
167-
return await this.getNewETagContent(versionTag)
168-
} catch (err) {
169-
getLogger('lsp').error('Failed to fetch at endpoint: %s, err: %s', this.resource, err)
170-
throw err
171-
}
172-
},
173-
{
174-
timeout: this.requestTimeoutMs,
175-
interval: this.retryIntervalMs,
176-
retryOnFail: true,
177-
}
178-
)
179-
}
180-
}
181-
182137
/**
183138
* Retrieves JSON property value from a remote resource
184139
* @param property property to retrieve

packages/webpack.web.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module.exports = (env, argv) => {
4141
* environments. The following allows compilation to pass in Web mode by never bundling the module in the final output for web mode.
4242
*/
4343
new webpack.IgnorePlugin({
44-
resourceRegExp: /httpResourceFetcher/, // matches the path in the require() statement
44+
resourceRegExp: /node\/httpResourceFetcher/, // matches the path in the require() statement
4545
}),
4646
/**
4747
* HACK: the ps-list module breaks Web mode if imported, BUT we still dynamically import this module for non web mode

0 commit comments

Comments
 (0)