diff --git a/app/build.gradle b/app/build.gradle index 8449ad4..177c30f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,6 @@ plugins { // Gradle doesn't allow conditionally enabling/disabling plugins - id "io.sentry.android.gradle" version "3.3.0" + id "io.sentry.android.gradle" version "3.4.0" id 'com.android.application' id 'com.mikepenz.aboutlibraries.plugin' } @@ -238,7 +238,7 @@ sentry { // Enable auto-installation of Sentry components (sentry-android SDK and okhttp, timber and fragment integrations). autoInstallation { - sentryVersion = '6.10.0' + sentryVersion = '6.11.0' } } @@ -277,7 +277,7 @@ dependencies { implementation 'com.github.topjohnwu.libsu:io:5.0.1' implementation 'com.github.Fox2Code:RosettaX:1.0.9' implementation 'com.github.Fox2Code:AndroidANSI:1.0.1' - implementation 'io.sentry:sentry-android:6.10.0' + implementation 'io.sentry:sentry-android:6.11.0' // Markdown implementation "io.noties.markwon:core:4.6.2" diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java b/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java index a4bd000..6fb5933 100644 --- a/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java +++ b/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java @@ -41,14 +41,14 @@ public class RepoUpdater { return 0; } this.indexRaw = Http.doHttpGet(this.repoData.getUrl(), false); - this.toUpdate = this.repoData.populate(new JSONObject( - new String(this.indexRaw, StandardCharsets.UTF_8))); + this.toUpdate = this.repoData.populate(new JSONObject(new String(this.indexRaw, StandardCharsets.UTF_8))); // Since we reuse instances this should work this.toApply = new HashSet<>(this.repoData.moduleHashMap.values()); this.toApply.removeAll(this.toUpdate); // Return repo to update return this.toUpdate.size(); - } catch (Exception e) { + } catch ( + Exception e) { Log.e(TAG, "Failed to get manifest of " + this.repoData.id, e); this.indexRaw = null; this.toUpdate = Collections.emptyList(); @@ -74,9 +74,11 @@ public class RepoUpdater { if (this.indexRaw != null) { try { Files.write(this.repoData.metaDataCache, this.indexRaw); - if (BuildConfig.DEBUG) { Log.d(TAG, "Wrote index of " + this.repoData.id); + if (BuildConfig.DEBUG) { + Log.d(TAG, "Wrote index of " + this.repoData.id); } - } catch (IOException e) { + } catch ( + IOException e) { e.printStackTrace(); } this.indexRaw = null; diff --git a/app/src/main/java/com/fox2code/mmm/utils/SyncManager.java b/app/src/main/java/com/fox2code/mmm/utils/SyncManager.java index f0d85c8..d47bbb4 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/SyncManager.java +++ b/app/src/main/java/com/fox2code/mmm/utils/SyncManager.java @@ -3,6 +3,8 @@ package com.fox2code.mmm.utils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.fox2code.mmm.repo.RepoManager; + /** * Manager that want both to be thread safe and not to worry about thread safety * {@link #scan()} and {@link #update(UpdateListener)} can be called from multiple @@ -27,6 +29,10 @@ public abstract class SyncManager { // MultiThread friendly method public final void update(@Nullable UpdateListener updateListener) { + // fail fast on no internet + if (!RepoManager.getINSTANCE().hasConnectivity()) { + return; + } if (updateListener == null) updateListener = NO_OP; if (!this.syncing) { // Do scan @@ -60,10 +66,6 @@ public abstract class SyncManager { } } - public final boolean isRepoUpdating() { - return this.syncing; - } - public final void afterUpdate() { if (this.syncing) synchronized (this.syncLock) { Thread.yield(); } }