New issue
Advanced search Search tips

Issue 689655 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Feb 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

base::ReplaceFile on Windows gives misleading error codes if to_path doesn't exist

Project Member Reported by csharrison@chromium.org, Feb 7 2017

Issue description

The function first tries to MoveFile(), and retries with ReplaceFile on error.

However, if to_path doesn't exist originally, only MoveFile can succeed. ReplaceFile will fail with NOT_FOUND, as it needs to_path to exist. Since we unconditionally retry with ReplaceFile, we always receive NOT_FOUND if MoveFile fails, masking the error from MoveFile.

If the function is attempting to support cases when to_path doesn't exist, it would be nice if this were fixed.

+chengx who looks to be the last person to work on windows file stuff.
 
Description: Show this description
Owner: csharrison@chromium.org
Provisional patch:
https://codereview.chromium.org/2681643005/
Project Member

Comment 3 by bugdroid1@chromium.org, Feb 8 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b281ba4e35f9d2f1b28c6e92cae971f048025eb6

commit b281ba4e35f9d2f1b28c6e92cae971f048025eb6
Author: csharrison <csharrison@chromium.org>
Date: Wed Feb 08 13:03:26 2017

Report more relevant error code for windows base::ReplaceFile impl

The windows version of base::ReplaceFile performs a MoveFile, followed by
a ReplaceFile if the move fails.

However, if the to_path does not exist, and the MoveFile fails, the
error reported by ReplaceFile will always be a NOT_FOUND, because
ReplaceFile requires the to_path to exist.

This patch just fowards the MoveFile error when the ReplaceFile's error
is NOT_FOUND. It will be more or equally as relevant.

BUG= 689655 

Review-Url: https://codereview.chromium.org/2681643005
Cr-Commit-Position: refs/heads/master@{#448970}

[modify] https://crrev.com/b281ba4e35f9d2f1b28c6e92cae971f048025eb6/base/files/file_util_win.cc

Status: Fixed (was: Untriaged)

Sign in to add a comment