diff options
author | Young Gyu Park <younggyu@google.com> | 2018-05-24 14:22:31 +0900 |
---|---|---|
committer | Young Gyu Park <younggyu@google.com> | 2018-05-24 14:22:31 +0900 |
commit | c314aad8253d6e376a17d3728e63e4cfcd495cf1 (patch) | |
tree | 49d086418959f24a6ffa8865f4ffae3f708843ea /src/main/java | |
parent | 3b8326d5bd720dc18a9ac3e50847f858df062b61 (diff) | |
download | dashboard-c314aad8253d6e376a17d3728e63e4cfcd495cf1.tar.gz |
Bug fix of some reports not uploaded
Test: go/vts-web-staging/show_gcs_log?path=cts-on-gsi/cts-on-gsi/gs://vts-release/v8.1/latest/test_suite/arm_64/walleye-user_latest_20180517-164606/
Bug: 79964560
Change-Id: Ie51998e8ffde87a5423a4f9260f0a4c10e4c540b
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/android/vts/servlet/ShowGcsLogServlet.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/main/java/com/android/vts/servlet/ShowGcsLogServlet.java b/src/main/java/com/android/vts/servlet/ShowGcsLogServlet.java index f9b6f85..82624ce 100644 --- a/src/main/java/com/android/vts/servlet/ShowGcsLogServlet.java +++ b/src/main/java/com/android/vts/servlet/ShowGcsLogServlet.java @@ -35,6 +35,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; @@ -78,7 +79,8 @@ public class ShowGcsLogServlet extends BaseServlet { public void init(ServletConfig cfg) throws ServletException { super.init(cfg); - this.keyFileInputStream = this.getClass().getClassLoader().getResourceAsStream("keys/" + GCS_KEY_FILE); + this.keyFileInputStream = + this.getClass().getClassLoader().getResourceAsStream("keys/" + GCS_KEY_FILE); Optional<Storage> optionalStorage = GcsHelper.getStorage(this.keyFileInputStream); if (optionalStorage.isPresent()) { @@ -215,15 +217,17 @@ public class ShowGcsLogServlet extends BaseServlet { if (pathInfo.getNameCount() == 0) { listOptions = new BlobListOption[] {BlobListOption.currentDirectory()}; } else { + String prefixPathString = path.endsWith("/") ? path : path.concat("/"); if (pathInfo.getNameCount() <= 1) { dirList.add("/"); } else { - dirList.add(pathInfo.getParent().toString()); + dirList.add(getParentDirPath(prefixPathString)); } + listOptions = new BlobListOption[] { BlobListOption.currentDirectory(), - BlobListOption.prefix(pathInfo.toString() + "/") + BlobListOption.prefix(prefixPathString) }; } @@ -254,4 +258,15 @@ public class ShowGcsLogServlet extends BaseServlet { } } } + + private String getParentDirPath(String fileOrDirPath) { + boolean endsWithSlashCheck = fileOrDirPath.endsWith(File.separator); + return fileOrDirPath.substring( + 0, + fileOrDirPath.lastIndexOf( + File.separatorChar, + endsWithSlashCheck + ? fileOrDirPath.length() - 2 + : fileOrDirPath.length() - 1)); + } } |