summaryrefslogtreecommitdiff
path: root/deps/uv/src/win/fs.c
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-01-18 13:37:29 -0500
committercjihrig <cjihrig@gmail.com>2019-01-21 10:28:17 -0500
commitf698386c7e988ef45027a75b2ff988899ee2af1d (patch)
tree37d9c39baf7fb03e472701436410e8e461086174 /deps/uv/src/win/fs.c
parent27871c35b685dd599710e57e76a66ee3a82c1e6d (diff)
downloadandroid-node-v8-f698386c7e988ef45027a75b2ff988899ee2af1d.tar.gz
android-node-v8-f698386c7e988ef45027a75b2ff988899ee2af1d.tar.bz2
android-node-v8-f698386c7e988ef45027a75b2ff988899ee2af1d.zip
deps: upgrade to libuv 1.25.0
PR-URL: https://github.com/nodejs/node/pull/25571 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Diffstat (limited to 'deps/uv/src/win/fs.c')
-rw-r--r--deps/uv/src/win/fs.c72
1 files changed, 2 insertions, 70 deletions
diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c
index 0716ecca12..65d936bf08 100644
--- a/deps/uv/src/win/fs.c
+++ b/deps/uv/src/win/fs.c
@@ -42,8 +42,6 @@
#define UV_FS_FREE_PTR 0x0008
#define UV_FS_CLEANEDUP 0x0010
-#define UV__RENAME_RETRIES 4
-#define UV__RENAME_WAIT 250
#define INIT(subtype) \
do { \
@@ -1360,78 +1358,12 @@ static void fs__fstat(uv_fs_t* req) {
static void fs__rename(uv_fs_t* req) {
- int tries;
- int sys_errno;
- int result;
- int try_rmdir;
- WCHAR* src, *dst;
- DWORD src_attrib, dst_attrib;
-
- src = req->file.pathw;
- dst = req->fs.info.new_pathw;
- try_rmdir = 0;
-
- /* Do some checks to fail early. */
- src_attrib = GetFileAttributesW(src);
- if (src_attrib == INVALID_FILE_ATTRIBUTES) {
+ if (!MoveFileExW(req->file.pathw, req->fs.info.new_pathw, MOVEFILE_REPLACE_EXISTING)) {
SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
- dst_attrib = GetFileAttributesW(dst);
- if (dst_attrib != INVALID_FILE_ATTRIBUTES) {
- if (dst_attrib & FILE_ATTRIBUTE_READONLY) {
- req->result = UV_EPERM;
- return;
- }
- /* Renaming folder to a folder name that already exist will fail on
- * Windows. We will try to delete target folder first.
- */
- if (src_attrib & FILE_ATTRIBUTE_DIRECTORY &&
- dst_attrib & FILE_ATTRIBUTE_DIRECTORY)
- try_rmdir = 1;
- }
-
- /* Sometimes an antivirus or indexing software can lock the target or the
- * source file/directory. This is annoying for users, in such cases we will
- * retry couple of times with some delay before failing.
- */
- for (tries = 0; tries < UV__RENAME_RETRIES; ++tries) {
- if (tries > 0)
- Sleep(UV__RENAME_WAIT);
-
- if (try_rmdir) {
- result = _wrmdir(dst) == 0 ? 0 : uv_translate_sys_error(_doserrno);
- switch (result)
- {
- case 0:
- case UV_ENOENT:
- /* Folder removed or did not exist at all. */
- try_rmdir = 0;
- break;
- case UV_ENOTEMPTY:
- /* Non-empty target folder, fail instantly. */
- SET_REQ_RESULT(req, -1);
- return;
- default:
- /* All other errors - try to move file anyway and handle the error
- * there, retrying folder deletion next time around.
- */
- break;
- }
- }
-
- if (MoveFileExW(src, dst, MOVEFILE_REPLACE_EXISTING) != 0) {
- SET_REQ_RESULT(req, 0);
- return;
- }
- sys_errno = GetLastError();
- result = uv_translate_sys_error(sys_errno);
- if (result != UV_EBUSY && result != UV_EPERM && result != UV_EACCES)
- break;
- }
- req->sys_errno_ = sys_errno;
- req->result = result;
+ SET_REQ_RESULT(req, 0);
}