sromku / android-storage

Create, read, delete, append, encrypt files and more, on internal or external disk spaces with a really simple API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

isDirectoryExists method creates directory instead of just checking up

artemtrofimov opened this issue · comments

commented

What you should do to reproduce the bug
Storage storage = SimpleStorage.getInternalStorage(context); Log.e("1", "does " + DIR_PATH + " exist " + storage.isDirectoryExists(DIR_PATH);
Always returns true, because this method actually creates the dir.

Why does this happen?
AbstractDiskStorage invokes buildPath(name) inside isDirectoryExists(String name).
buildPath(name) has context.getDir(directoryName, Context.MODE_PRIVATE) in InternalStorage implementation.
getDir method creates the dir if it does not already exist.

You are totally right and it's a bug. Fixed in latest version.