Commit 8fd2f984 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed returned size in bytes of offline messages. JM-423

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@2911 b35dd754-fafc-0310-a699-88a17e54d16e
parent 2d651f43
......@@ -179,6 +179,8 @@ public class OfflineMessageStore extends BasicModule {
pstmt = con.prepareStatement(DELETE_OFFLINE);
pstmt.setString(1, username);
pstmt.executeUpdate();
removeUsernameFromSizeCache(username);
}
}
catch (Exception e) {
......@@ -257,6 +259,8 @@ public class OfflineMessageStore extends BasicModule {
pstmt = con.prepareStatement(DELETE_OFFLINE);
pstmt.setString(1, username);
pstmt.executeUpdate();
removeUsernameFromSizeCache(username);
}
catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
......@@ -269,6 +273,13 @@ public class OfflineMessageStore extends BasicModule {
}
}
private void removeUsernameFromSizeCache(String username) {
// Update the cached size if it exists.
if (sizeCache.containsKey(username)) {
sizeCache.remove(username);
}
}
/**
* Deletes the specified offline message in the store for a user. The way to identify the
* message to delete is based on the creationDate and username.
......@@ -285,6 +296,11 @@ public class OfflineMessageStore extends BasicModule {
pstmt.setString(1, username);
pstmt.setString(2, StringUtils.dateToMillis(creationDate));
pstmt.executeUpdate();
//force a refresh for next call to getSize(username)
//its easier than loading the msg to be deleted just
//to update the cache.
removeUsernameFromSizeCache(username);
}
catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment