mirror of https://gitlab.com/bashrc2/epicyon
More descriptive variable name
parent
ec74a69c6a
commit
80339ecf20
22
shares.py
22
shares.py
|
@ -1011,19 +1011,15 @@ def mergeSharedItemTokens(baseDir: str, domain: str,
|
||||||
"""
|
"""
|
||||||
removals = []
|
removals = []
|
||||||
changed = False
|
changed = False
|
||||||
print('Test 46237')
|
|
||||||
for tokenDomain, tok in tokensJson.items():
|
for tokenDomain, tok in tokensJson.items():
|
||||||
print('tokenDomain: ' + tokenDomain)
|
|
||||||
if domain:
|
if domain:
|
||||||
if tokenDomain.startswith(domain):
|
if tokenDomain.startswith(domain):
|
||||||
continue
|
continue
|
||||||
if tokenDomain not in newSharedItemsFederatedDomains:
|
if tokenDomain not in newSharedItemsFederatedDomains:
|
||||||
removals.append(tokenDomain)
|
removals.append(tokenDomain)
|
||||||
print('remove ' + tokenDomain)
|
|
||||||
# remove domains no longer in the federation list
|
# remove domains no longer in the federation list
|
||||||
for tokenDomain in removals:
|
for tokenDomain in removals:
|
||||||
del tokensJson[tokenDomain]
|
del tokensJson[tokenDomain]
|
||||||
print('removing ' + tokenDomain)
|
|
||||||
changed = True
|
changed = True
|
||||||
# add new domains from the federation list
|
# add new domains from the federation list
|
||||||
for tokenDomain in newSharedItemsFederatedDomains:
|
for tokenDomain in newSharedItemsFederatedDomains:
|
||||||
|
@ -1131,26 +1127,26 @@ def _updateFederatedSharesCache(session, sharedItemsFederatedDomains: [],
|
||||||
asHeader = {
|
asHeader = {
|
||||||
'Accept': 'application/ld+json'
|
'Accept': 'application/ld+json'
|
||||||
}
|
}
|
||||||
for otherDomain in sharedItemsFederatedDomains:
|
for federatedDomain in sharedItemsFederatedDomains:
|
||||||
# NOTE: otherDomain does not have a port extension,
|
# NOTE: federatedDomain does not have a port extension,
|
||||||
# so may not work in some situations
|
# so may not work in some situations
|
||||||
if otherDomain.startswith(domain):
|
if federatedDomain.startswith(domain):
|
||||||
# only download from instances other than this one
|
# only download from instances other than this one
|
||||||
continue
|
continue
|
||||||
if not tokensJson.get(otherDomain):
|
if not tokensJson.get(federatedDomain):
|
||||||
# token has been obtained for the other domain
|
# token has been obtained for the other domain
|
||||||
continue
|
continue
|
||||||
url = httpPrefix + '://' + otherDomain + '/catalog'
|
url = httpPrefix + '://' + federatedDomain + '/catalog'
|
||||||
asHeader['Authorization'] = tokensJson[otherDomain]
|
asHeader['Authorization'] = tokensJson[federatedDomain]
|
||||||
catalogJson = getJson(session, url, asHeader, None,
|
catalogJson = getJson(session, url, asHeader, None,
|
||||||
debug, __version__, httpPrefix, None)
|
debug, __version__, httpPrefix, None)
|
||||||
if not catalogJson:
|
if not catalogJson:
|
||||||
print('WARN: failed to download shared items catalog for ' +
|
print('WARN: failed to download shared items catalog for ' +
|
||||||
otherDomain)
|
federatedDomain)
|
||||||
continue
|
continue
|
||||||
catalogFilename = catalogsDir + '/' + otherDomain + '.json'
|
catalogFilename = catalogsDir + '/' + federatedDomain + '.json'
|
||||||
if saveJson(catalogJson, catalogFilename):
|
if saveJson(catalogJson, catalogFilename):
|
||||||
print('Downloaded shared items catalog for ' + otherDomain)
|
print('Downloaded shared items catalog for ' + federatedDomain)
|
||||||
else:
|
else:
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue