mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Fix similar empty-cursor bug when creating a folder on open.
Turn tabs into spaces in code I changed last commit.
This commit is contained in:
parent
4f798ae9cc
commit
6cd5ce7dee
@ -337,25 +337,21 @@ public class LocalStore extends Store {
|
|||||||
}
|
}
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
cursor = mDb.rawQuery("SELECT id, unread_count, visible_limit FROM folders "
|
cursor = mDb.rawQuery(
|
||||||
+ "where folders.name = ?",
|
"SELECT id, unread_count, visible_limit FROM folders "
|
||||||
new String[] {
|
+ "where folders.name = ?",
|
||||||
mName
|
new String[] { mName });
|
||||||
});
|
if (cursor.moveToFirst()) {
|
||||||
if ( cursor.getCount() == 0 ) {
|
mFolderId = cursor.getInt(0);
|
||||||
// Calling exists on open is a little expensive. Instead, just handle it when we don't find it.
|
mUnreadMessageCount = cursor.getInt(1);
|
||||||
|
mVisibleLimit = cursor.getInt(2);
|
||||||
|
} else {
|
||||||
|
// Calling exists on open is a little expensive. Instead,
|
||||||
|
// just handle it when we don't find it.
|
||||||
create(FolderType.HOLDS_MESSAGES);
|
create(FolderType.HOLDS_MESSAGES);
|
||||||
open(mode);
|
open(mode);
|
||||||
|
|
||||||
}
|
}
|
||||||
cursor.moveToFirst();
|
} finally {
|
||||||
mFolderId = cursor.getInt(0);
|
|
||||||
mUnreadMessageCount = cursor.getInt(1);
|
|
||||||
mVisibleLimit = cursor.getInt(2);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
@ -379,23 +375,23 @@ public class LocalStore extends Store {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean exists() throws MessagingException {
|
public boolean exists() throws MessagingException {
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
cursor = mDb.rawQuery("SELECT id FROM folders "
|
cursor = mDb.rawQuery("SELECT id FROM folders "
|
||||||
+ "where folders.name = ?",
|
+ "where folders.name = ?", new String[] { this
|
||||||
new String[] { this.getName() });
|
.getName() });
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
int folderId = cursor.getInt(0);
|
int folderId = cursor.getInt(0);
|
||||||
return (folderId > 0) ? true : false;
|
return (folderId > 0) ? true : false;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean create(FolderType type) throws MessagingException {
|
public boolean create(FolderType type) throws MessagingException {
|
||||||
|
Loading…
Reference in New Issue
Block a user