Skip to content

Commit

Permalink
Ignore backup files in getAllKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsAreku authored and pilgr committed Mar 27, 2019
1 parent 450f13e commit 6900010
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions paperdb/src/main/java/io/paperdb/DbStoragePlainFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -33,6 +34,7 @@
import static io.paperdb.Paper.TAG;

public class DbStoragePlainFile {
private static final String BACKUP_EXTENSION = ".bak";

private final String mDbPath;
private final HashMap<Class, Serializer> mCustomSerializers;
Expand Down Expand Up @@ -193,7 +195,12 @@ synchronized List<String> getAllKeys() {
assertInit();

File bookFolder = new File(mDbPath);
String[] names = bookFolder.list();
String[] names = bookFolder.list(new FilenameFilter() {
@Override
public boolean accept(File file, String s) {
return !s.endsWith(BACKUP_EXTENSION);
}
});
if (names != null) {
//remove extensions
for (int i = 0; i < names.length; i++) {
Expand Down Expand Up @@ -346,7 +353,7 @@ private static boolean deleteDirectory(String dirPath) {
}

private File makeBackupFile(File originalFile) {
return new File(originalFile.getPath() + ".bak");
return new File(originalFile.getPath() + BACKUP_EXTENSION);
}

/**
Expand Down

0 comments on commit 6900010

Please sign in to comment.