You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val url ="$GitHubApiPrefix/contents/$LibrariesDir/$LibraryPropertiesFile?ref=$commitSha"
131
+
log.info("Checking current library descriptor format version from $url")
132
+
val response = getHttp(url)
133
+
val downloadUrl = (response asJSONObject)["download_url"].toString()
134
+
val downloadResult = getHttp(downloadUrl)
135
+
val result = downloadResult.text.parseIniConfig()["formatVersion"]!!.toInt()
136
+
log.info("Current library descriptor format version: $result")
137
+
result
138
+
}
139
+
118
140
/***
119
141
* Downloads library descriptors from GitHub to local cache if new commits in `libraries` directory were detected
120
142
*/
@@ -126,7 +148,7 @@ fun downloadNewLibraryDescriptors() {
126
148
val footprintFilePath =Paths.get(LocalSettingsPath, LocalCacheDir, CachedLibrariesFootprintFile).toString()
127
149
log.info("Reading commit info for which library descriptors were cached: '$footprintFilePath'")
128
150
val footprintFile =File(footprintFilePath)
129
-
val footprint = footprintFile.readIniConfig()
151
+
val footprint = footprintFile.tryReadIniConfig()
130
152
val timestampRegex ="""\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z""".toRegex()
131
153
val syncedCommitTimestamp = footprint?.get("timestamp")?.validOrNull { timestampRegex.matches(it) }
132
154
val syncedCommitSha = footprint?.get("sha")
@@ -138,26 +160,33 @@ fun downloadNewLibraryDescriptors() {
138
160
return
139
161
}
140
162
163
+
// Download library descriptor version
164
+
165
+
val descriptorVersion = getLibraryDescriptorVersion(latestCommitSha) ?:return
166
+
if (descriptorVersion != libraryDescriptorFormatVersion) {
167
+
if (descriptorVersion < libraryDescriptorFormatVersion)
168
+
log.error("Incorrect library descriptor version in GitHub repository: $descriptorVersion")
169
+
else
170
+
log.warn("Couldn't download new library descriptors from GitHub repository because their format was updated. Please, update kotlin jupyter kernel to the latest version")
171
+
return
172
+
}
173
+
141
174
// Download library descriptors
142
175
143
176
log.info("New commits to library descriptors were detected. Downloading library descriptors for commit $latestCommitSha")
144
177
145
178
val libraries = log.catchAll {
146
179
val url ="$GitHubApiPrefix/contents/$LibrariesDir?ref=$latestCommitSha"
147
180
log.info("Requesting the list of library descriptors at $url")
148
-
val response = khttp.get(url)
149
-
if (response.statusCode !=200)
150
-
throwException("Failed to get GitHub contents for '$LibrariesDir' from $url. Response = $response")
181
+
val response = getHttp(url)
151
182
152
183
response.jsonArray.mapNotNull {
153
184
val o = it asJSONObject
154
185
val filename = o["name"] asString
155
186
if ("""[\w-]+.$LibraryDescriptorExt""".toRegex().matches(filename)) {
156
187
val libUrl = o["download_url"].toString()
157
188
log.info("Downloading '$filename' from $libUrl")
158
-
val res = khttp.get(libUrl)
159
-
if (res.statusCode !=200)
160
-
throwException("Failed to download '$filename' from $libUrl. Response = $res")
0 commit comments