Skip to content

org.h2.tools.DeleteDbFiles won't delete files under certain circumstances #3493

@sco0ter

Description

@sco0ter

org.h2.tools.DeleteDbFiles has following issue with case sensitivity:

Let's say my database is called "AAA.mv.db" and I pass "AAA" to org.h2.tools.DeleteDbFiles.execute() in order to delete all files associated with it.
Let's also say, I have a sub-folder aaa in my database directory (which is also passed to execute()

Later:

String start = db == null ? null : (FileUtils.toRealPath(dir + "/" + db) + ".");

=> start will be aaa, i.e. it found the sub-folder.

Later the startsWith will fail, due to different cases ('AAA' vs. 'aaa'):

if (db == null || f.startsWith(start)) {
    files.add(f);
}

files won't contain the actual DB files associated with AAA, so they won't be deleted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions