DarkoKukovec / crypto-fs

Wrapper around node fs module that encrypts the files on the fly
MIT License
3 stars 6 forks source link

Unable to make readdir() in the root folder #23

Open arttarasov opened 6 years ago

arttarasov commented 6 years ago

Each call to the encrypted storage goes through filename.getPath() or filename.getPathSync() functions. readdir() called with empty string, '.' or / as a path will transform it to _/ that doesn't exist. So there is no way to read the content of the root folder. Only known subfolders may be read. It happens at least with the aes-256-cbc algorithm. For example, if I change default algorithm in your project from aes-256-ctr to aes-256-cbc, readdir and readdirSync tests fail because folderPath become .../crypto-fs/test/test/c8907dbcf8da255ce8ac0a297509f2a1/c8907dbcf8da255ce8ac0a297509f2a1 instead of .../crypto-fs\test\test_ as it looks with the aes-256-ctr algorithm.