dain / leveldb

Port of LevelDB to Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read any leveldb (IndexedDB) from Skype for Desktop

dyorgio opened this issue · comments

Hi!

I tried to use this lib without success to read two leveldb produced by Skype app:

SKYPE_DATA_DIR/IndexedDB/file__0.indexeddb.leveldb
and
SKYPE_DATA_DIR/Local Storage/leveldb.

For the first I needed to register a custom comparator: idb_cmp1

options.comparator(new DBComparator() {
    @Override
    public String name() {
        return "idb_cmp1";
    }

    @Override
    public byte[] findShortestSeparator(byte[] start, byte[] limit) {
        return start;
    }

    @Override
    public byte[] findShortSuccessor(byte[] key) {
        return key;
    }

    @Override
    public int compare(byte[] o1, byte[] o2) {
        return new String(o1).compareTo(new String(o2));
    }
});

But for both I received this error:

Exception in thread "main" java.lang.NullPointerException
	at org.iq80.leveldb.util.Snappy.uncompress(Snappy.java:234)
	at org.iq80.leveldb.table.MMapTable.readBlock(MMapTable.java:121)
	at org.iq80.leveldb.table.Table.openBlock(Table.java:80)
	at org.iq80.leveldb.util.TableIterator.getNextBlock(TableIterator.java:102)
	at org.iq80.leveldb.util.TableIterator.getNextElement(TableIterator.java:79)
	at org.iq80.leveldb.util.AbstractSeekingIterator.hasNext(AbstractSeekingIterator.java:48)
	at org.iq80.leveldb.util.InternalTableIterator.getNextElement(InternalTableIterator.java:51)
	at org.iq80.leveldb.util.AbstractSeekingIterator.hasNext(AbstractSeekingIterator.java:48)
	at org.iq80.leveldb.util.DbIterator.resetPriorityQueue(DbIterator.java:155)
	at org.iq80.leveldb.util.DbIterator.<init>(DbIterator.java:75)
	at org.iq80.leveldb.impl.DbImpl.internalIterator(DbImpl.java:778)
	at org.iq80.leveldb.impl.DbImpl.iterator(DbImpl.java:744)
	at org.iq80.leveldb.impl.DbImpl.iterator(DbImpl.java:735)
	at org.iq80.leveldb.impl.DbImpl.iterator(DbImpl.java:84)

I already tried to disable compression on Options.

Did anyone read Skype App database with this lib? (aka Electron/Chromium IndexedDB)

Looking at the code, that stack ends at https://github.com/dain/leveldb/blob/master/leveldb/src/main/java/org/iq80/leveldb/util/Snappy.java#L234, which would imply that snappy did not load properly. I'd use a debugger and figure out why.

Thank you @dain!
Puttiing snappy dep in my pom solve this issue, maybe converting NPE to something like this:

public static void uncompress(ByteBuffer compressed, ByteBuffer uncompressed)
        throws IOException
{
    checkSnappy();
    SNAPPY.uncompress(compressed, uncompressed);
}

private void checkSnappy() {
    if (SNAPPY == null) throw new RuntimeException("Compressed database, snappy library not found in your classpath.");
}

Help future users ;)

I really didn't guess that it is a required lib for this case.