@@ -296,23 +296,58 @@ ClassMethod ReadUplinksFromFile() As %Status
296
296
// DateTime hasn't changed - skip file
297
297
Return sc
298
298
}
299
- set obj = ##class (YAML.Utils ).FileToJSON (" /usr/irissys/zpm-registry.yaml" , .sc )
299
+ set obj = ##class (YAML.Utils ).FileToJSON (tFilename , .sc )
300
+
300
301
$$$ThrowOnError(sc )
301
- Set joUplinks = obj ." uplinks"
302
- &sql (TRUNCATE TABLE ZPM .UpLink )
303
- Set iter = joUplinks .%GetIterator ()
304
- Set position = 0
305
- While iter .%GetNext (.key , .joOneUplink ) {
306
- Set position = position + 1
307
- Do ..AddUplink (key , joOneUplink .url , joOneUplink ." allow_packages" , position )
302
+ Set filemodificationTS = tFile .DateModified
303
+ If (..IsDefaultConfig (obj )) {
304
+ // namespace doesn't specified
305
+ Do ..SaveUplinks (obj ." uplinks" , filemodificationTS )
306
+ } Else {
307
+ // namespace specified - search for current ns settings
308
+ Set iter = obj .%GetIterator ()
309
+ Set ns = $$$lcase($NAMESPACE )
310
+ While iter .%GetNext (.key , .uplinks ) {
311
+ If (ns = $$$lcase(key )) {
312
+ Do ..SaveUplinks (uplinks ." uplinks" , filemodificationTS )
313
+ }
314
+ }
308
315
}
309
- Set ^zpmregistry (" filemodified" ) = tFile .DateModified
310
316
} Catch ex {
311
317
Set sc = ex .AsStatus ()
312
318
}
313
319
Return sc
314
320
}
315
321
322
+ ClassMethod SaveUplinks (joUplinks As %DynamicObject , filemodificationTS As %String ) As %Status
323
+ {
324
+ &sql (TRUNCATE TABLE ZPM .UpLink )
325
+ Set iter = joUplinks .%GetIterator ()
326
+ Set position = 0
327
+ While iter .%GetNext (.key , .joOneUplink ) {
328
+ Set position = position + 1
329
+ Do ..AddUplink (key , joOneUplink .url , joOneUplink ." allow_packages" , position )
330
+ }
331
+ Set ^zpmregistry (" filemodified" ) = filemodificationTS
332
+ }
333
+
334
+ ClassMethod IsDefaultConfig (obj As %DynamicObject ) As %Boolean
335
+ {
336
+ Try {
337
+ If (obj .%GetTypeOf (" uplinks" )=" object" ) {
338
+ Set iter = obj .uplinks .%GetIterator ()
339
+ If iter .%GetNext (.key , .joOneUplink ) {
340
+ If (joOneUplink .%IsDefined (" url" )) {
341
+ return 1
342
+ }
343
+ }
344
+ }
345
+ } Catch ex {
346
+ return 0
347
+ }
348
+ return 0
349
+ }
350
+
316
351
ClassMethod AddUplink (name , url , allowList , position ) As %Status
317
352
{
318
353
If (url = " " ) { return 0 }
0 commit comments