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

Update cache when awsconfig file changes #2946

Merged
merged 6 commits into from
Aug 23, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -705,19 +705,18 @@ JSONObject getHostedUIJSON() {
JSONObject getHostedUIJSON(final AWSConfiguration awsConfig) {
try {
JSONObject hostedUIJSONFromJSON = getHostedUIJSONFromJSON(awsConfig);
if (hostedUIJSONFromJSON == null) {
return null;
}

final String hostedUIString = mStore.get(HOSTED_UI_KEY);
JSONObject hostedUIJSON = null;
try {
hostedUIJSON = new JSONObject(hostedUIString);
} catch (Exception e) {
Log.w(TAG,
"Failed to parse HostedUI settings from store. Defaulting to awsconfiguration.json", e);
"Failed to parse HostedUI settings from store", e);
}
if (hostedUIJSON == null && hostedUIJSONFromJSON != null) {

// Since there is no file watcher to keep track of when config file changes, this logic is intended to always check if the config file is different from mstore cache and updates the later accordingly.
// If config file cannot be loaded, the mstore data still prevails.
if (hostedUIJSONFromJSON != null && (hostedUIJSON == null || hostedUIJSON.toString() != hostedUIJSONFromJSON.toString())) {
banji180 marked this conversation as resolved.
Show resolved Hide resolved
div5yesh marked this conversation as resolved.
Show resolved Hide resolved
hostedUIJSON = new JSONObject(hostedUIJSONFromJSON.toString());
mStore.set(HOSTED_UI_KEY, hostedUIJSON.toString());
}
Expand Down