Skip to content

Commit 140ba05

Browse files
committed
fix: inaccurate error message when pull not required
1 parent ed609ff commit 140ba05

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

app/src/main/java/com/viscouspot/gitsync/MainActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ class MainActivity : AppCompatActivity() {
366366
{
367367
networkRequired(applicationContext)
368368
},
369-
) { }
369+
null
370+
)
370371

371372
if (result == false) {
372373
makeToast(applicationContext, getString(R.string.pull_failed))

app/src/main/java/com/viscouspot/gitsync/util/GitManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@ class GitManager(private val context: Context, private val settingsManager: Sett
235235
return false
236236
}
237237

238-
fun downloadChanges(userStorageUri: Uri, scheduleNetworkSync: () -> Unit, onSync: () -> Unit): Boolean? {
238+
fun downloadChanges(userStorageUri: Uri, scheduleNetworkSync: () -> Unit, onSync: (() -> Unit)?): Boolean? {
239239
if (conditionallyScheduleNetworkSync(scheduleNetworkSync)) {
240240
return null
241241
}
242242
try {
243-
var returnResult: Boolean? = false
243+
var returnResult: Boolean? = onSync == null
244244
log(LogType.PullFromRepo, "Getting local directory")
245245
val repo = FileRepository("${Helper.getPathFromUri(context, userStorageUri)}/${context.getString(R.string.git_path)}")
246246
val git = Git(repo)
@@ -262,7 +262,7 @@ class GitManager(private val context: Context, private val settingsManager: Sett
262262

263263
if (!fetchResult.trackingRefUpdates.isEmpty() || !localHead.equals(remoteHead)) {
264264
log(LogType.PullFromRepo, "Pulling changes")
265-
onSync.invoke()
265+
onSync?.invoke()
266266
val result = git.pull().apply {
267267
applyCredentials(this)
268268
setRemote(settingsManager.getRemote())

0 commit comments

Comments
 (0)