You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2018/02/06 22:49:38 UTC

[1/2] mesos git commit: Windows: Fixed `fs::list` to return full paths.

Repository: mesos
Updated Branches:
  refs/heads/master a79fe26ac -> 8e7afafb9


Windows: Fixed `fs::list` to return full paths.

This resolves MESOS-7803, where `fs::list` only returned the name of the
found files, dropping the initial path components. That is, for a
directory `foo` with the file `bar` in it, and the pattern
`fs::list("foo/*")`, it was incorrectly returning just `bar`, not
`foo/bar`. This was fixed by getting the `dirname` of the pattern, and
rejoining it with each found file name before it is returned.

Review: https://reviews.apache.org/r/65397/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e71ed38c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e71ed38c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e71ed38c

Branch: refs/heads/master
Commit: e71ed38c650f256fef65312980d6ef1d70adf7d9
Parents: a79fe26
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Tue Feb 6 14:47:57 2018 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Tue Feb 6 14:47:57 2018 -0800

----------------------------------------------------------------------
 3rdparty/stout/include/stout/windows/fs.hpp | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e71ed38c/3rdparty/stout/include/stout/windows/fs.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/windows/fs.hpp b/3rdparty/stout/include/stout/windows/fs.hpp
index bc7cf02..cc9a560 100644
--- a/3rdparty/stout/include/stout/windows/fs.hpp
+++ b/3rdparty/stout/include/stout/windows/fs.hpp
@@ -92,6 +92,7 @@ inline Try<Nothing> symlink(
 // `/root/dir/subdir/*.txt` or `/root/dir/subdir/file?.txt`.
 inline Try<std::list<std::string>> list(const std::string& pattern)
 {
+  const std::string dirname(Path(pattern).dirname());
   std::list<std::string> found_files;
   WIN32_FIND_DATAW found;
   const SharedHandle search_handle(
@@ -101,14 +102,12 @@ inline Try<std::list<std::string>> list(const std::string& pattern)
   if (search_handle.get() == INVALID_HANDLE_VALUE) {
     // For compliance with the POSIX implementation (which uses `::glob`),
     // return an empty list instead of an error when the path does not exist.
-    int error = ::GetLastError();
+    const DWORD error = ::GetLastError();
     if (error == ERROR_FILE_NOT_FOUND || error == ERROR_PATH_NOT_FOUND) {
       return found_files;
     }
 
-    return WindowsError(
-        "'fs::list' failed when searching for files with pattern '" +
-        pattern + "'");
+    return WindowsError(error, "FindFirstFile failed");
   }
 
   do {
@@ -116,16 +115,13 @@ inline Try<std::list<std::string>> list(const std::string& pattern)
 
     // Ignore `.` and `..` entries.
     if (current_file.compare(L".") != 0 && current_file.compare(L"..") != 0) {
-      found_files.push_back(stringify(current_file));
+      found_files.push_back(path::join(dirname, stringify(current_file)));
     }
   } while (::FindNextFileW(search_handle.get(), &found));
 
   const DWORD error = ::GetLastError();
   if (error != ERROR_NO_MORE_FILES) {
-    return WindowsError(
-        error,
-        "'fs::list': 'FindNextFile' failed when searching for files with "
-        "'pattern '" + pattern + "'");
+    return WindowsError(error, "FindNextFile failed");
   }
 
   return found_files;


[2/2] mesos git commit: Removed workaround in ZooKeeper test.

Posted by an...@apache.org.
Removed workaround in ZooKeeper test.

Now that `fs::list` returns the full path, this code can be fixed.

Review: https://reviews.apache.org/r/65398/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8e7afafb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8e7afafb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8e7afafb

Branch: refs/heads/master
Commit: 8e7afafb9056c04d2ff849011a9e8f79a2f9ce6a
Parents: e71ed38
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Tue Feb 6 14:48:33 2018 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Tue Feb 6 14:48:33 2018 -0800

----------------------------------------------------------------------
 src/tests/zookeeper.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8e7afafb/src/tests/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/zookeeper.cpp b/src/tests/zookeeper.cpp
index 54cf9c6..722ea0b 100644
--- a/src/tests/zookeeper.cpp
+++ b/src/tests/zookeeper.cpp
@@ -72,12 +72,11 @@ void ZooKeeperTest::SetUpTestCase()
 
     foreach (const string& jar, jars.get()) {
 #ifdef __WINDOWS__
-      // TODO(andschwa): `fs::list` on Windows only returns the file names, not
-      // the full paths. Remove this work-around when MESOS-7803 is resolved.
-      classpath += ";" + path::join(zkHome, "lib", jar);
+      classpath += ";";
 #else
-      classpath += ":" + jar;
+      classpath += ":";
 #endif
+      classpath += jar;
     }
 
     LOG(INFO) << "Using Java classpath: " << classpath;