cryptomator / dokany-nio-adapter

Dokany-based adapter to provide directory contents specified by a java.nio.file.Path (via dokan-java)
GNU Affero General Public License v3.0
14 stars 4 forks source link

Performance: Open FileChannel only when necessary #22

Closed infeo closed 5 years ago

infeo commented 5 years ago

Dokany-nio-adapter version: 1.1.4

Currently a file channel is always openend when a handle to a file is created, even when the file channel is not used until the closeFile() call.

This can be improved by switching from opening file channels preemptive to only when a real readFile() or writeFile() call is made.

infeo commented 5 years ago

Because in zwCreateFile() the caller expects that the error codes are true to this point in time this is not a valid approach:

Imagine if someone opens a file with CREATE_NEW flag, but the actual file channel is opened later. In the meantime another process could have already created the file and thus for the first process this would lead to an error.