@@ -4,7 +4,7 @@ module Constants = {
44 let alsWithSquirrel = "$(squirrel) ALS v"
55 let downloadLatestALS = "$(cloud-download) Download the latest Agda Language Server"
66 let openDownloadFolder = "$(folder-opened) Open download folder"
7- let clearCache = "$(trash) Clear cache "
7+ let deleteDownloads = "$(trash) Delete downloads "
88 let downloadedAndInstalled = "Downloaded and installed"
99 let otherDownloads = "$(chevron-right) Other Downloads"
1010 let otherDownloadsDesc = "Browse other versions available for download"
@@ -17,7 +17,7 @@ module ItemData = {
1717 | DownloadAction (bool , string , string ) // downloaded, versionString, downloadType
1818 | OtherVersionsSubmenu // submenu button for other versions downloads
1919 | OpenFolder (string ) // folderPath
20- | ClearCache // clear release cache
20+ | DeleteDownloads // delete downloads and clear cache
2121 | NoInstallations
2222 | Separator (string ) // label
2323
@@ -41,7 +41,7 @@ module ItemData = {
4141 downloadType
4242 | OtherVersionsSubmenu => "OtherVersionsSubmenu"
4343 | OpenFolder (folderPath ) => "OpenFolder: " ++ folderPath
44- | ClearCache => "ClearCache "
44+ | DeleteDownloads => "DeleteDownloads "
4545 | NoInstallations => "NoInstallations"
4646 | Separator (label ) => "Separator: " ++ label
4747 }
@@ -141,7 +141,7 @@ module ItemData = {
141141 }
142142
143143 // Add misc section
144- Array .concat (sectionsWithDownload , [Separator ("Misc" ), OpenFolder (folderPath ), ClearCache ])
144+ Array .concat (sectionsWithDownload , [Separator ("Misc" ), OpenFolder (folderPath ), DeleteDownloads ])
145145 }
146146}
147147
@@ -193,9 +193,9 @@ module Item = {
193193 let description = "Where the language servers are downloaded to"
194194 (label , Some (description ), Some (folderPath ))
195195 }
196- | ClearCache => {
197- let label = Constants .clearCache
198- let description = "Clear all cached data "
196+ | DeleteDownloads => {
197+ let label = Constants .deleteDownloads
198+ let description = "Delete all downloaded files and clear cached release metadata "
199199 (label , Some (description ), None )
200200 }
201201 | NoInstallations => {
@@ -872,13 +872,21 @@ module Handler = {
872872 module PlatformOps = unpack (platformDeps )
873873 await PlatformOps .openFolder (globalStorageUriAsFile )
874874 state .channels .log -> Chan .emit (Log .SwitchVersionUI (SelectionCompleted ))
875- } else if selectedItem .label == Constants .clearCache {
875+ } else if selectedItem .label == Constants .deleteDownloads {
876+ // Delete download directories recursively
877+ let deleteDir = async dirName => {
878+ let uri = VSCode .Uri .joinPath (state .globalStorageUri , [dirName ])
879+ let _ = await FS .deleteRecursive (uri )
880+ }
881+ await deleteDir ("dev-wasm-als" )
882+ await deleteDir ("dev-als" )
883+ await deleteDir ("latest-als" )
876884 // Clear cache for all repositories
877885 await Memento .ALSReleaseCache .clear (state .memento , "agda" , "agda-language-server" )
878886 await Memento .ALSReleaseCache .clear (state .memento , "banacorn" , "agda-language-server" )
879887 await Memento .PickedConnection .clear (state .memento )
880888 await Memento .Endpoints .clear (state .memento )
881- let _ = await VSCode .Window .showInformationMessage ("Cache cleared " , [])
889+ let _ = await VSCode .Window .showInformationMessage ("All downloads and cache deleted " , [])
882890 state .channels .log -> Chan .emit (Log .SwitchVersionUI (SelectionCompleted ))
883891 } else if selectedItem .label == Constants .downloadLatestALS {
884892 // Handle latest ALS download
0 commit comments