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

Maintain correct source order even when receiving new chapters from a sync service #1360

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

Lolle2000la
Copy link

@Lolle2000la Lolle2000la commented Dec 12, 2024

Fixes #1339

Problem description and origin

If chapters are pushed to a sync service from Device A and these new chapters are then received by Device B, the source order of these chapters will be wrong because the existing chapters have not gotten their source order adjusted. This source order usually changes when new chapters get added or old ones get removed, however, as-is local chapters will still be in the order of before with the new chapters now colliding with the old chapters (leading to orders like "Chapter 38" -> "Chapter 43" -> "Chapter 37" -> "Chapter 42" -> ...).

How this PR fixes the problem

The proposed changes now ensure that this corner case for syncing is caught and the sourceOrder of the chapters are now in the correct order. I made it so that existing behavior not sync-related should remain unaffected.

Screenshot illustrating the problem

393552769-3519cc72-ca2d-4d0d-9144-0cc6e6b45288 - Copy

@jobobby04
Copy link
Owner

jobobby04 commented Dec 17, 2024

It was a lint error, you can run the automatic formatter by doing ./gradlew :spotlessApply which should fix all those.

@Lolle2000la
Copy link
Author

Lolle2000la commented Dec 17, 2024

Thank you! I will keep that in mind in the future.

It was a lint error, you can run the automatic formatter by doing ./gradlew :spotlessApply which should fix all those.

./gradlew :spotlessApply didn't work but ./gradlew spotlessApply did, just if someone else stumbles upon this (most likely me).

@jobobby04
Copy link
Owner

I always forget if it needs the : before the task 😄

@jobobby04 jobobby04 merged commit a32c718 into jobobby04:master Dec 17, 2024
2 checks passed
@Lolle2000la Lolle2000la deleted the fix-wrong-sync-order branch December 17, 2024 17:30
cuong-tran pushed a commit to komikku-app/komikku that referenced this pull request Dec 18, 2024
… sync service (jobobby04/TachiyomiSY#1360)

* Maintain correct source order even when receiving new chapters from sync service

* Add comma required by build service

(cherry picked from commit a32c7186e43fe616c5956f04c0cef50b450d97c1)
@Lolle2000la
Copy link
Author

Lolle2000la commented Dec 19, 2024

Just in case someone stumbles upon this for unrelated reasons, I am now using the following git pre-commit hook, which shoud work on both Windows and Linus and should make sure no commits get made in an invalid state:

#!/bin/bash

echo "Running pre-commit hook (./gradlew spotlessApply)."

# Navigate to the repository root directory temporarily.
REPO_ROOT=$(git rev-parse --show-toplevel)
pushd "$REPO_ROOT" >/dev/null || {
  echo "Failed to change directory to repository root. Aborting pre-commit hook."
  exit 1
}

# Capture the output of the Gradle spotlessApply task.
OUTPUT=$(./gradlew spotlessApply 2>&1)
EXIT_CODE=$?

# Stage all changes made by spotlessApply.
git add -u

# Restore the original directory
popd >/dev/null

if [ $EXIT_CODE -ne 0 ]; then
  echo "spotlessApply failed. Aborting commit."
  echo "$OUTPUT"
  exit $EXIT_CODE
fi

echo "spotlessApply completed successfully. Proceeding with commit."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Order of chapters wrong when received through sync
2 participants