base::ReplaceFile on Windows gives misleading error codes if to_path doesn't exist |
||
Issue descriptionThe 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.
,
Feb 7 2017
,
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
,
Feb 9 2017
|
||
►
Sign in to add a comment |
||
Comment 1 by csharrison@chromium.org
, Feb 7 2017