Skip to content

Commit

Permalink
PersistentHashMap's remove method works properly now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe0 committed May 28, 2013
1 parent 1655bc8 commit 0811355
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/com/jamierf/persistenthashmap/PersistentHashMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,17 @@ public synchronized V remove(Object key) {
keyFile.delete();
valueFile.delete();

// TODO: We also need to delete their directories if empty otherwise isEmpty() will fail...
// TODO: Shift any subsequent files down
while(!keyFile.getParentFile().equals(keyStore)
&& keyFile.getParentFile().listFiles().length == 0) {
keyFile.getParentFile().delete();
keyFile = keyFile.getParentFile();
}

while(!valueFile.getParentFile().equals(valueStore)
&& valueFile.getParentFile().listFiles().length == 0) {
valueFile.getParentFile().delete();
valueFile = valueFile.getParentFile();
}

return oldValue;
}
Expand Down

0 comments on commit 0811355

Please sign in to comment.