@@ -39,8 +39,6 @@ const githubReleaseApiValidator: validate.Validator<IRelease[]> = validate.array
39
39
40
40
const cachedReleaseValidator : validate . Validator < IRelease [ ] | null > = validate . optional ( githubReleaseApiValidator ) ;
41
41
42
- const cachedReleaseValidatorOld : validate . Validator < IRelease | null > = validate . optional ( releaseValidator ) ;
43
-
44
42
// On Windows the executable needs to be stored somewhere with an .exe extension
45
43
const exeExt = process . platform === 'win32' ? '.exe' : '' ;
46
44
@@ -223,36 +221,10 @@ async function getReleaseMetadata(context: ExtensionContext, storagePath: string
223
221
224
222
const offlineCache = path . join ( storagePath , 'approvedReleases.cache.json' ) ;
225
223
226
- async function readCachedReleaseData ( fallBack : boolean ) : Promise < IRelease [ ] | null > {
224
+ async function readCachedReleaseData ( ) : Promise < IRelease [ ] | null > {
227
225
try {
228
226
const cachedInfo = await promisify ( fs . readFile ) ( offlineCache , { encoding : 'utf-8' } ) ;
229
227
return validate . parseAndValidate ( cachedInfo , cachedReleaseValidator ) ;
230
- } catch ( err : any ) {
231
- // If file doesn't exist, return null unless fallBack is true. In that case try to
232
- // read from the older cache file format (1.7.1 and earlier).
233
- // Consider everything else it a failure
234
- if ( err . code === 'ENOENT' ) {
235
- if ( fallBack ) {
236
- return readOldCachedReleaseData ( ) ;
237
- } else {
238
- return null ;
239
- }
240
- }
241
- throw err ;
242
- }
243
- }
244
-
245
- const offlineCacheOld = path . join ( storagePath , 'latestApprovedRelease.cache.json' ) ;
246
-
247
- async function readOldCachedReleaseData ( ) : Promise < IRelease [ ] | null > {
248
- try {
249
- const cachedInfo = await promisify ( fs . readFile ) ( offlineCacheOld , { encoding : 'utf-8' } ) ;
250
- const cached = validate . parseAndValidate ( cachedInfo , cachedReleaseValidatorOld ) ;
251
- if ( cached ) {
252
- return [ cached ] ;
253
- } else {
254
- return null ;
255
- }
256
228
} catch ( err : any ) {
257
229
// If file doesn't exist, return null, otherwise consider it a failure
258
230
if ( err . code === 'ENOENT' ) {
@@ -261,12 +233,11 @@ async function getReleaseMetadata(context: ExtensionContext, storagePath: string
261
233
throw err ;
262
234
}
263
235
}
264
-
265
236
// Not all users want to upgrade right away, in that case prompt
266
237
const updateBehaviour = workspace . getConfiguration ( 'haskell' ) . get ( 'updateBehavior' ) as UpdateBehaviour ;
267
238
268
239
if ( updateBehaviour === 'never-check' ) {
269
- return readCachedReleaseData ( true )
240
+ return readCachedReleaseData ( ) ;
270
241
}
271
242
272
243
try {
@@ -275,7 +246,7 @@ async function getReleaseMetadata(context: ExtensionContext, storagePath: string
275
246
validate . parseAndValidate ( releaseInfo , githubReleaseApiValidator ) . filter ( ( x ) => ! x . prerelease ) || null ;
276
247
277
248
if ( updateBehaviour === 'prompt' ) {
278
- const cachedInfoParsed = await readCachedReleaseData ( false ) ;
249
+ const cachedInfoParsed = await readCachedReleaseData ( ) ;
279
250
280
251
if (
281
252
releaseInfoParsed !== null && releaseInfoParsed . length > 0 &&
@@ -290,7 +261,7 @@ async function getReleaseMetadata(context: ExtensionContext, storagePath: string
290
261
const decision = await window . showInformationMessage ( promptMessage , 'Download' , 'Nevermind' ) ;
291
262
if ( decision !== 'Download' ) {
292
263
// If not upgrade, bail and don't overwrite cached version information
293
- return readCachedReleaseData ( true ) ;
264
+ return cachedInfoParsed ;
294
265
}
295
266
}
296
267
}
@@ -301,7 +272,7 @@ async function getReleaseMetadata(context: ExtensionContext, storagePath: string
301
272
} catch ( githubError : any ) {
302
273
// Attempt to read from the latest cached file
303
274
try {
304
- const cachedInfoParsed = await readCachedReleaseData ( true ) ;
275
+ const cachedInfoParsed = await readCachedReleaseData ( ) ;
305
276
306
277
window . showWarningMessage (
307
278
`Couldn't get the latest haskell-language-server releases from GitHub, used local cache instead:\n${ githubError . message } `
0 commit comments