Skip to content

Commit

Permalink
Fix media sync comparison and a consequent DB error
Browse files Browse the repository at this point in the history
  • Loading branch information
hssm committed Jan 2, 2017
1 parent 3db873f commit e2b07c5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
7 changes: 1 addition & 6 deletions AnkiDroid/src/main/java/com/ichi2/anki/MyAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,7 @@ private void logout() {
editor.putString("hkey", "");
editor.commit();
// force media resync on deauth
try {
getCol().getMedia().forceResync();
} catch (SQLiteException e) {
Timber.e("MyAccount.logout() reinitializing media db due to sqlite error");
getCol().getMedia()._initDB();
}
getCol().getMedia().forceResync();
switchToState(STATE_LOG_IN);
}

Expand Down
3 changes: 2 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/libanki/Media.java
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,8 @@ public int dirtyCount() {
public void forceResync() {
mDb.execute("delete from media");
mDb.execute("update meta set lastUsn=0,dirMod=0");
mDb.execute("vacuum analyze");
mDb.execute("vacuum");
mDb.execute("analyze");
mDb.commit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public String sync() throws UnknownHttpResponseException, MediaSyncException {

} else if (!TextUtils.isEmpty(lsum)) {
// deleted remotely
if (ldirty != 0) {
if (ldirty == 0) {
mCol.log("delete local");
mCol.getMedia().syncDelete(fname);
} else {
Expand Down

0 comments on commit e2b07c5

Please sign in to comment.