Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugifx/vscode multiple windows install #4359

Merged
merged 3 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Fixed a bug where multiple Visual Studio Code instances would make the extension install/update fail. [#3686](https://github.com/microsoft/kiota/issues/3686)
- PREVIEW: Renamed the config commands to workspace. [#4310](https://github.com/microsoft/kiota/issues/4310)
- PREVIEW: Moved preview configuration files to the .kiota directory. [#4310](https://github.com/microsoft/kiota/issues/4310)
- PREVIEW: Moved the copy descriptions to dedicated folders. [#4310](https://github.com/microsoft/kiota/issues/4310)
Expand Down
2 changes: 1 addition & 1 deletion vscode/microsoft-kiota/l10n/bundle.l10n.ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Enter an output path relative to the root of the project": "أدخل مسار إخراج في جذر المشروع",
"Pick a language": "اختر لغة",
"Downloading kiota requires an internet connection. Please check your connection and try again.": "يتطلب تنزيل kiota اتصالا بالإنترنت. يرجى التحقق من اتصالك والمحاولة مرة أخرى.",
"Kiota download failed. Check the extension host logs for more information.": "فشل تنزيل Kiota. تحقق من سجلات مضيف الإضافة للحصول على مزيد من المعلومات.",
"Kiota download failed. Try closing all Visual Studio Code windows and open only one. Check the extension host logs for more information.": "فشل تنزيل Kiota. تحقق من سجلات مضيف الإضافة للحصول على مزيد من المعلومات.",
"Downloading kiota...": "جاري تنزيل Kiota...",
"Generating client...": "انشاء العميل...",
"Loading...": "جاري التحميل...",
Expand Down
2 changes: 1 addition & 1 deletion vscode/microsoft-kiota/l10n/bundle.l10n.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Enter an output path relative to the root of the project": "Ingrese una dirección para el producto relativa al root del proyecto",
"Pick a language": "Seleccione un lenguaje",
"Downloading kiota requires an internet connection. Please check your connection and try again.": "Desgargar Kiota requiere de conexión a internet. Por favor, revise su conexión e intente de nuevo.",
"Kiota download failed. Check the extension host logs for more information.": "Descarga de Kiota fallida. Revise la bitácora del host de la extensión para más información.",
"Kiota download failed. Try closing all Visual Studio Code windows and open only one. Check the extension host logs for more information.": "La descarga de Kiota ha fallado. Intente cerrar todas las ventanas en Visual Studio Code y abrir solamente una. Revise los registros de la extensión para más información.",
"Downloading kiota...": "Descargando Kiota...",
"Generating client...": "Generando cliente...",
"Updating clients...": "Actualizando clientes...",
Expand Down
2 changes: 1 addition & 1 deletion vscode/microsoft-kiota/l10n/bundle.l10n.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Enter an output path relative to the root of the project": "Entrez un chemin relatif à la racine du projet",
"Pick a language": "Sélectionnez un langage",
"Downloading kiota requires an internet connection. Please check your connection and try again.": "Télécharger Kiota nécessite une connexion Internet. Vérifiez votre connexion et réessayez.",
"Kiota download failed. Check the extension host logs for more information.": "Échec du téléchargement de Kiota. Vérifiez les journaux de l'hôte d'extension pour plus d'informations.",
"Kiota download failed. Try closing all Visual Studio Code windows and open only one. Check the extension host logs for more information.": "Échec du téléchargement de Kiota. Essayez de fermer toutes les fenêtres de Visual Studio Code et d'en ouvrir une seule. Vérifiez les journaux de l'hôte d'extension pour plus d'informations.",
"Downloading kiota...": "Téléchargement de Kiota...",
"Generating client...": "Génération du client...",
"Updating clients...": "Mise à jour des clients...",
Expand Down
2 changes: 1 addition & 1 deletion vscode/microsoft-kiota/l10n/bundle.l10n.it.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Enter an output path relative to the root of the project": "Inserisci un path di output relativo alla root del progetto",
"Pick a language": "Seleziona un linguaggio",
"Downloading kiota requires an internet connection. Please check your connection and try again.": "Il download di kiota richiede una connessione internet. Controlla la tua connessione e riprova.",
"Kiota download failed. Check the extension host logs for more information.": "Il download di kiota è fallito. Controlla i log dell'host per maggiori informazioni.",
"Kiota download failed. Try closing all Visual Studio Code windows and open only one. Check the extension host logs for more information.": "Il download di Kiota è fallito. Prova a chiudere tutte le finestre di Visual Studio Code ed aprirne una sola. Controlla i log per maggiori informazioni.",
"Downloading kiota...": "Download di kiota in corso...",
"Generating client...": "Generazione del client in corso...",
"Updating clients...": "Aggiornamento dei client in corso...",
Expand Down
2 changes: 1 addition & 1 deletion vscode/microsoft-kiota/l10n/bundle.l10n.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"Enter an output path relative to the root of the project": "出力先をプロジェクトのルートからの相対パスで入力",
"Pick a language": "言語を選択",
"Downloading kiota requires an internet connection. Please check your connection and try again.": "Kiotaのダウンロードにはインターネット接続が必要です。インターネット接続を確認して再試行してください。",
"Kiota download failed. Check the extension host logs for more information.": "Kiotaのダウンロードに失敗しました。拡張機能のホストログを確認してください。",
"Kiota download failed. Try closing all Visual Studio Code windows and open only one. Check the extension host logs for more information.": "Kiotaのダウンロードに失敗しました。拡張機能のホストログを確認してください。",
"Downloading kiota...": "Kiotaをダウンロード中...",
"Generating client...": "クライアントを生成中...",
"Updating clients...": "クライアントを更新中...",
Expand Down
2 changes: 1 addition & 1 deletion vscode/microsoft-kiota/l10n/bundle.l10n.pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Enter an output path relative to the root of the project": "Insira o caminho relativo da saída da raiz do projeto",
"Pick a language": "Selecione uma linguagem",
"Downloading kiota requires an internet connection. Please check your connection and try again.": "Para baixar o Kiota é necessário uma conexão de internet. Por favor, verifique sua conexão e tente novamente.",
"Kiota download failed. Check the extension host logs for more information.": "O download do Kiota falhou. Por favor, verifique os logs do host para mais informações.",
"Kiota download failed. Try closing all Visual Studio Code windows and open only one. Check the extension host logs for more information.": "O download do Kiota falhou. Tente fechar todas as janelas do Visual Studio Code e abrir somente uma. Verifique os logs do host da extensão para mais informações.",
"Downloading kiota...": "Baixando o Kiota...",
"Generating client...": "Gerando o cliente...",
"Updating clients...": "Atualizando os clientes...",
Expand Down
2 changes: 1 addition & 1 deletion vscode/microsoft-kiota/l10n/bundle.l10n.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"Enter an output path relative to the root of the project": "Введите путь вывода относительно корня проекта",
"Pick a language": "Выберите язык",
"Downloading kiota requires an internet connection. Please check your connection and try again.": "Для загрузки Kiota требуется подключение к интернету. Пожалуйста, проверьте ваше подключение и попробуйте еще раз.",
"Kiota download failed. Check the extension host logs for more information.": "Скачивание Kiota не удалось. Для получения дополнительной информации проверьте журналы хост-процесс для расширений.",
"Kiota download failed. Try closing all Visual Studio Code windows and open only one. Check the extension host logs for more information.": "Загрузка Kiota не удалась. Попробуйте закрыть все окна Visual Studio Code и открыть только одно. Проверьте журналы хоста расширений для получения дополнительной информации.",
"Downloading kiota...": "Идет загрузка Kiota...",
"Generating client...": "Генерирование клиента...",
"Updating clients...": "Обновление клиентов...",
Expand Down
2 changes: 1 addition & 1 deletion vscode/microsoft-kiota/l10n/bundle.l10n.sw.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Enter an output path relative to the root of the project": "Ingiza eneo inayohusiana na mzizi wa mradi",
"Pick a language": "Chagua lugha",
"Downloading kiota requires an internet connection. Please check your connection and try again.": "Kupakua Kiota inahitaji muunganisho wa intaneti. Tafadhali angalia muunganisho wako kisha ujaribu tena.",
"Kiota download failed. Check the extension host logs for more information.": "Upakuaji wa Kiota haukufaulu. Angalia kumbukumbu za seva kwa maelezo zaidi..",
"Kiota download failed. Try closing all Visual Studio Code windows and open only one. Check the extension host logs for more information.": "Upakuaji wa Kiota haukufaulu. Jaribu kufunga dirisha zote za Visual Studio Code kisha ufungue moja tu. Angalia kumbukumbu za seva kwa maelezo zaidi",
"Downloading kiota...": "Inapakua Kiota...",
"Generating client...": "Inatengeneza mteja...",
"Updating clients...": "Inasasisha wateja...",
Expand Down
2 changes: 1 addition & 1 deletion vscode/microsoft-kiota/l10n/bundle.l10n.tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Enter an output path relative to the root of the project": "Proje köküne göre bir çıktı yolu girin",
"Pick a language": "Bir dil seçin",
"Downloading kiota requires an internet connection. Please check your connection and try again.": "Kiota'nın indirilmesi bir internet bağlantısı gerektirir. Lütfen bağlantınızı kontrol edin ve tekrar deneyin.",
"Kiota download failed. Check the extension host logs for more information.": "Kiota indirme başarısız oldu. Daha fazla bilgi için uzantı log kayıtlarını kontrol edin.",
"Kiota download failed. Try closing all Visual Studio Code windows and open only one. Check the extension host logs for more information.": "Kiota indirme başarısız oldu. Daha fazla bilgi için uzantı log kayıtlarını kontrol edin.",
"Downloading kiota...": "Kiota indiriliyor...",
"Generating client...": "İstemci oluşturuluyor...",
"Updating clients...": "İstemciler güncelleniyor...",
Expand Down
2 changes: 1 addition & 1 deletion vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"Enter an output path relative to the root of the project": "请输入相对根路径的输出路径",
"Pick a language": "请选择一个语言",
"Downloading kiota requires an internet connection. Please check your connection and try again.": "下载Kiota需要网络连接。请检查您是否成功连接网络。",
"Kiota download failed. Check the extension host logs for more information.": "Kiota下载失败。请检查托管扩展记录。",
"Kiota download failed. Try closing all Visual Studio Code windows and open only one. Check the extension host logs for more information.": "Kiota下载失败。请检查托管扩展记录。",
"Downloading kiota...": "正在下载Kiota...",
"Generating client...": "正在生成客户端...",
"Updating clients...": "正在更新客户端...",
Expand Down
14 changes: 7 additions & 7 deletions vscode/microsoft-kiota/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"displayName": "Microsoft Kiota",
"publisher": "ms-graph",
"description": "Client generator for HTTP REST APIs described by OpenAPI which helps eliminate the need to take a dependency on a different API client for every API that you need to call, as well as limiting the generation to the exact API surface area you're interested in, thanks to a filtering capability.",
"version": "1.10.100000002",
"kiotaVersion": "1.10.1",
"version": "1.12.100000001",
"kiotaVersion": "1.12.0",
"telemetryInstrumentationKey": "4c6357e0-daf9-42b5-bdfb-67878f8957b5",
"icon": "images/logo.png",
"engines": {
Expand Down Expand Up @@ -450,23 +450,23 @@
"runtimeDependencies": [
{
"platformId": "win-x64",
"sha256": "F14DA204DBB513B12995C006DD4A356C8498EFF087BA77EE84E06C18AE92A947"
"sha256": "04884ED264534CCE1708F0377809A98BFBE73F1B916432B71845CFF426B4E15D"
},
{
"platformId": "win-x86",
"sha256": "1E55DDEBC4EC8AC8B527C7681FD342A2CFB74150914DD1E9669B84DAF26E18D5"
"sha256": "9324A3B58889B0DD123B478608E6A59FED3147B3268C4EF37F172BC9517B1233"
},
{
"platformId": "linux-x64",
"sha256": "311F765AEC73477501B1C6EA97C0EAF108144318CB1C7C39D20B3CEE4C5DF848"
"sha256": "C093782E42DFA98574A1503D27F661F54F1C8CA92B66F6ED7B9DF475447E1769"
},
{
"platformId": "osx-x64",
"sha256": "82843F91BEC078C9344BAFFE7D8B7FB87BDAD7160329AF221BCEBA2C10DD0B50"
"sha256": "7911E277474EFF71D00C9983A9F3E43460F5C3C3FBB565CFE069854BA4069FCD"
},
{
"platformId": "osx-arm64",
"sha256": "FD8EE5E60432E2885B4DE0E650D92829EE5EA4D20C50E7CB7D3E7B2FCDCDCB9B"
"sha256": "032AFBCF63FFF1C21215277E5EAFDD1909E1EFE5213B15F52ED4BBBDF3695C0A"
}
]
}
66 changes: 43 additions & 23 deletions vscode/microsoft-kiota/src/kiotaInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,34 @@ import * as admZip from 'adm-zip';
import * as vscode from "vscode";
import isOnline from 'is-online';


const kiotaInstallStatusKey = "kiotaInstallStatus";
const installDelayInMs = 30000; // 30 seconds
andrueastman marked this conversation as resolved.
Show resolved Hide resolved
async function runIfNotLocked(context: vscode.ExtensionContext, action: () => Promise<void>) {
const installStartTimeStamp = context.globalState.get<number>(kiotaInstallStatusKey);
const currentTimeStamp = new Date().getTime();
if (!installStartTimeStamp || (currentTimeStamp - installStartTimeStamp) > installDelayInMs) {
//locking the context to prevent multiple downloads across multiple instances of vscode
//overriding after 30 seconds to prevent stale locks
await context.globalState.update(kiotaInstallStatusKey, currentTimeStamp);
try {
await action();
} finally {
await context.globalState.update(kiotaInstallStatusKey, undefined);
}
}
}
export async function ensureKiotaIsPresent(context: vscode.ExtensionContext) {
const runtimeDependencies = getRuntimeDependenciesPackages(context);
const currentPlatform = getCurrentPlatform();
const installPath = getKiotaPathInternal(context, false);
if (installPath) {
if (!fs.existsSync(installPath)) {
if (!fs.existsSync(installPath) || fs.readdirSync(installPath).length === 0) {
await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
cancellable: false,
title: vscode.l10n.t("Downloading kiota...")

}, async (progress, _) => {
const online = await isOnline();
if (!online) {
Expand All @@ -24,29 +42,31 @@ export async function ensureKiotaIsPresent(context: vscode.ExtensionContext) {
);
return;
}
try {
const packageToInstall = runtimeDependencies.find((p) => p.platformId === currentPlatform);
if (!packageToInstall) {
throw new Error("Could not find package to install");
}
fs.mkdirSync(installPath, { recursive: true });
const zipFilePath = `${installPath}.zip`;
await downloadFileFromUrl(getDownloadUrl(context, currentPlatform), zipFilePath);
if (await doesFileHashMatch(zipFilePath, packageToInstall.sha256)) {
unzipFile(zipFilePath, installPath);
const kiotaPath = getKiotaPathInternal(context);
if ((currentPlatform.startsWith(linuxPlatform) || currentPlatform.startsWith(osxPlatform)) && kiotaPath) {
makeExecutable(kiotaPath);
await runIfNotLocked(context, async () => {
try {
const packageToInstall = runtimeDependencies.find((p) => p.platformId === currentPlatform);
if (!packageToInstall) {
throw new Error("Could not find package to install");
}
fs.mkdirSync(installPath, { recursive: true });
const zipFilePath = `${installPath}.zip`;
await downloadFileFromUrl(getDownloadUrl(context, currentPlatform), zipFilePath);
if (await doesFileHashMatch(zipFilePath, packageToInstall.sha256)) {
unzipFile(zipFilePath, installPath);
const kiotaPath = getKiotaPathInternal(context);
if ((currentPlatform.startsWith(linuxPlatform) || currentPlatform.startsWith(osxPlatform)) && kiotaPath) {
makeExecutable(kiotaPath);
}
} else {
throw new Error("Hash mismatch");
}
} catch(error) {
await vscode.window.showErrorMessage(
vscode.l10n.t("Kiota download failed. Try closing all Visual Studio Code windows and open only one. Check the extension host logs for more information.")
);
fs.rmdirSync(installPath, { recursive: true });
}
} else {
throw new Error("Hash mismatch");
}
} catch(error) {
await vscode.window.showErrorMessage(
vscode.l10n.t("Kiota download failed. Check the extension host logs for more information.")
);
fs.rmdirSync(installPath, { recursive: true });
}
});
});
}
}
Expand Down
Loading