From be0c616d38a471ce8aa7aeb6ee6531b5dc538ccc Mon Sep 17 00:00:00 2001 From: benrubson Date: Mon, 26 Mar 2018 22:19:06 +0200 Subject: [PATCH] Cygwin, correct delete When deleting a file, Windows first opens it, deletes it, and closes it. But Windows does not allow deleting opened files, so no need to check before deletion. --- encfs/DirNode.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/encfs/DirNode.cpp b/encfs/DirNode.cpp index 58e7ab7..649681e 100644 --- a/encfs/DirNode.cpp +++ b/encfs/DirNode.cpp @@ -739,7 +739,9 @@ int DirNode::unlink(const char *plaintextName) { Lock _lock(mutex); - int res = 0; +// Windows does not allow deleting opened files, so no need to check +// There is this "issue" however : https://github.com/billziss-gh/winfsp/issues/157 +#ifndef __CYGWIN__ if ((ctx != nullptr) && ctx->lookupNode(plaintextName)) { // If FUSE is running with "hard_remove" option where it doesn't // hide open files for us, then we can't allow an unlink of an open @@ -747,14 +749,16 @@ int DirNode::unlink(const char *plaintextName) { RLOG(WARNING) << "Refusing to unlink open file: " << cyName << ", hard_remove option " "is probably in effect"; - res = -EBUSY; - } else { - string fullName = rootDir + cyName; - res = ::unlink(fullName.c_str()); - if (res == -1) { - res = -errno; - VLOG(1) << "unlink error: " << strerror(-res); - } + return -EBUSY; + } +#endif + + int res = 0; + string fullName = rootDir + cyName; + res = ::unlink(fullName.c_str()); + if (res == -1) { + res = -errno; + VLOG(1) << "unlink error: " << strerror(-res); } return res;