diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-05-24 16:32:45 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-05-24 16:32:45 +0000 |
commit | 30257ba9a08cee77d28f193ce50522bae6a3e241 (patch) | |
tree | 417ad511b411b16a9b75d9891eb9aaf4d7512efe /src/main/java | |
parent | cbc85bb9ca316948975bba087be530286dd6803e (diff) | |
parent | c314aad8253d6e376a17d3728e63e4cfcd495cf1 (diff) | |
download | dashboard-30257ba9a08cee77d28f193ce50522bae6a3e241.tar.gz |
Merge "Bug fix of some reports not uploaded"
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)); + } } |