From 5b2b73fc659cbd89bb9dcb0d19ecec12cc1df830 Mon Sep 17 00:00:00 2001 From: mai93 Date: Mon, 1 Feb 2021 15:07:40 +0200 Subject: [PATCH] Update threshold for long path shortening to be 158 not 160 --- src/main/native/windows/util.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/native/windows/util.cc b/src/main/native/windows/util.cc index 0e46deef29880d..d88682d9206cef 100644 --- a/src/main/native/windows/util.cc +++ b/src/main/native/windows/util.cc @@ -212,7 +212,8 @@ wstring AsShortPath(wstring path, wstring* result) { return MakeErrorMessage(WSTR(__FILE__), __LINE__, L"AsShortPath", path, L"path is not normalized"); } - if (path.size() >= MAX_PATH && !HasSeparator(path)) { + // Comparing to MAX_PATH - 2 to fix https://github.com/bazelbuild/bazel/issues/12310 + if (path.size() >= MAX_PATH - 2 && !HasSeparator(path)) { return MakeErrorMessage(WSTR(__FILE__), __LINE__, L"AsShortPath", path, L"path is just a file name but too long"); } @@ -225,7 +226,8 @@ wstring AsShortPath(wstring path, wstring* result) { std::replace(path.begin(), path.end(), '/', '\\'); // Fast-track: the path is already short. - if (path.size() < MAX_PATH) { + // Comparing to MAX_PATH - 2 to fix https://github.com/bazelbuild/bazel/issues/12310 + if (path.size() < MAX_PATH - 2) { *result = path; return L""; }