moxystudio/node-proper-lockfile

lock file prior to existence

bmeck opened this issue · 4 comments

right now you cannot lock() a file unless it is already on disk, this makes it hard to guarantee that files can be locked while their content is still being generated but the filename needs to be reserved

Indeed, the issue is with the canonicalPath. I need to get the canonical path of the file to ensure that calls to lock() with relative/absolute/symlinks are resolved to the same file.

I could detect a ENOENT error and fallback to path.normalize if the file is not a symlink.
realpath gives ENOENT to symlinks pointing to non-existent files. In this situation, I think we should still error out.

What do you think?

that sounds fine

On Mon, Mar 2, 2015 at 8:15 PM, André Cruz notifications@github.com wrote:

Indeed, the issue is with the canonicalPath. I need to get the canonical
path of the file to ensure that calls to lock() with relative/absolute/etc
are resolved to the same file.

I could detect a ENOENT error and just fallback to path.normalize. What
od you think?


Reply to this email directly or view it on GitHub
#2 (comment)
.

I ended up taking another approach. I've changed the resolve option to realpath.
By default realpath is enabled to resolve symlinks. If you turn it off, it will skip that step and will also allow locking files that are not yet created. Will publish 0.6 shortly.

In your case you want to pass realpath: false

Done.