Skip to content

Commit

Permalink
possible workaround for issue in haiwen#423
Browse files Browse the repository at this point in the history
the problem seems to be that the first full sync works. But after that
subsequent incrementals fail.

So, to verify, disable incrementals and always query the MediaStore for
all images. (There is still the "file already exists?"-check. So it shouldn't
cause multiple uploads on the server).
  • Loading branch information
forouher committed Nov 23, 2015
1 parent 174a7a0 commit 64f3274
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions src/com/seafile/seadroid2/cameraupload/CameraSyncAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,27 +264,25 @@ private void uploadImages(SyncResult syncResult, DataManager dataManager) throws
return;

// we only want media added since the last complete sync
String selection = MediaStore.Images.ImageColumns.DATE_ADDED + " > ?";
String selection = "";
String[] selectionArgs;

if (bucketList.size() > 0) {
// also we only want media in one of the selected buckets...
selectionArgs = new String[bucketList.size() + 1];
selectionArgs[0] = Long.toString(settingsMgr.getCameraUploadSyncStampImage());
selectionArgs = new String[bucketList.size()];

String questionmarkList = "";
for (int i = 0; i < bucketList.size(); i++) {
selectionArgs[i + 1] = bucketList.get(i);
selectionArgs[i] = bucketList.get(i);
questionmarkList += "?,";
}
questionmarkList = questionmarkList.substring(0, questionmarkList.length() - 1); // remove last ","
selection += " AND " + MediaStore.Images.ImageColumns.BUCKET_ID + " IN (" + questionmarkList + ")";
selection += MediaStore.Images.ImageColumns.BUCKET_ID + " IN (" + questionmarkList + ")";
} else {
// ...or only from the Camera bucket
selectionArgs = new String[2];
selectionArgs[0] = Long.toString(settingsMgr.getCameraUploadSyncStampImage());
selectionArgs[1] = CAMERA_BUCKET_NAME;
selection += " AND " + MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " = ?";
selectionArgs = new String[1];
selectionArgs[0] = CAMERA_BUCKET_NAME;
selection += MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " = ?";
}

// fetch all new images from the ContentProvider since our last sync
Expand Down Expand Up @@ -330,27 +328,25 @@ private void uploadVideos(SyncResult syncResult, DataManager dataManager) throws


// we only want media added since the last complete sync
String selection = MediaStore.Video.VideoColumns.DATE_ADDED + " > ?";
String selection = "";
String[] selectionArgs;

if (bucketList.size() > 0) {
// also we only want media in one of the selected buckets...
selectionArgs = new String[bucketList.size() + 1];
selectionArgs[0] = Long.toString(settingsMgr.getCameraUploadSyncStampVideo());
selectionArgs = new String[bucketList.size()];

String questionmarkList = "";
for (int i = 0; i < bucketList.size(); i++) {
selectionArgs[i + 1] = bucketList.get(i);
selectionArgs[i] = bucketList.get(i);
questionmarkList += "?,";
}
questionmarkList = questionmarkList.substring(0, questionmarkList.length() - 1); // remove last ","
selection += " AND " + MediaStore.Video.VideoColumns.BUCKET_ID + " IN (" + questionmarkList + ")";
selection += MediaStore.Video.VideoColumns.BUCKET_ID + " IN (" + questionmarkList + ")";
} else {
// ...or only from the Camera bucket
selectionArgs = new String[2];
selectionArgs[0] = Long.toString(settingsMgr.getCameraUploadSyncStampVideo());
selectionArgs[1] = CAMERA_BUCKET_NAME;
selection += " AND " + MediaStore.Video.Media.BUCKET_DISPLAY_NAME + " = ?";
selectionArgs = new String[1];
selectionArgs[0] = CAMERA_BUCKET_NAME;
selection += MediaStore.Video.Media.BUCKET_DISPLAY_NAME + " = ?";
}

// fetch all new videos from the ContentProvider since our last sync
Expand Down

0 comments on commit 64f3274

Please sign in to comment.