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

solving incomplete camera upload #925

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

lingzerol
Copy link

The branch solves the problem of #911. It uses SQLite to faster the speed of checking whether the photo is in the server. And if the sync service is canceled, this code can continue to scan the photos in the next time. It ignore some exception to ensure that the synchronization of other photos is not affected.

@lingzerol lingzerol marked this pull request as ready for review March 2, 2022 06:46
Copy link

@danielvandenberg95 danielvandenberg95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall, I would love to have this merged and my files backed up again!

@@ -302,7 +306,7 @@ public void onPerformSync(android.accounts.Account account,

// wait for TransferService to connect
// Log.d(DEBUG_TAG, "waiting for transfer service");
int timeout = 1000; // wait up to a second
int timeout = 10000; // wait up to a second

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 seconds, comment is wrong.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry..., I forget to modify the comments. I will fix it in the next version.

while (!isCancelled() && cursor.moveToNext()) {
file_iter += 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amy reason to keep this comment line?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter_iter is to help us to check whether the camera uploading service has uploaded all images.

if (image_uri == null) {
syncResult.stats.numSkippedEntries++;
continue;
}
file = new File(Utils.getRealPathFromURI(SeadroidApplication.getAppContext(), image_uri, media));
// file = new File(Utils.getRealPathFromURI(SeadroidApplication.getAppContext(), image_uri, media));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to keep this line?

Copy link
Author

@lingzerol lingzerol Mar 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reducing IO times. Only access the photo until the photo is needed to upload to the server.

if (video_uri == null) {
syncResult.stats.numSkippedEntries++;
continue;
}
file = new File(Utils.getRealPathFromURI(SeadroidApplication.getAppContext(), video_uri, media));
// file = new File(Utils.getRealPathFromURI(SeadroidApplication.getAppContext(), video_uri, media));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to keep this line?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(multiple times in this commit.)

Copy link
Author

@lingzerol lingzerol Mar 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reducing IO times. Only access the photo until the photo is needed to upload to the server.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this line just to help others change the code as they want.

public boolean isInRepo(String bucketName, String filename, long filelength){
String prefix = filename.substring(0, filename.lastIndexOf("."));
String suffix = filename.substring(filename.lastIndexOf("."));
// Cursor c = database.query(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two search patterns. This search pattern is the same as the original code. Another we use in L196 is more strict than the original code, but faster.

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.

None yet

2 participants