You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by pt...@apache.org on 2014/04/29 19:08:27 UTC

[4/5] git commit: make sure log file path is fully resolved

make sure log file path is fully resolved


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/6904862f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/6904862f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/6904862f

Branch: refs/heads/master
Commit: 6904862f2da5519f34c209f7579060fc5731b2f1
Parents: 16c9679
Author: P. Taylor Goetz <pt...@gmail.com>
Authored: Mon Apr 28 16:39:46 2014 -0400
Committer: P. Taylor Goetz <pt...@gmail.com>
Committed: Mon Apr 28 16:39:46 2014 -0400

----------------------------------------------------------------------
 .../src/clj/backtype/storm/daemon/logviewer.clj | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/6904862f/storm-core/src/clj/backtype/storm/daemon/logviewer.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/daemon/logviewer.clj b/storm-core/src/clj/backtype/storm/daemon/logviewer.clj
index ef6f349..2a48f55 100644
--- a/storm-core/src/clj/backtype/storm/daemon/logviewer.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/logviewer.clj
@@ -33,18 +33,18 @@
 (defn tail-file [path tail root-dir]
   (let [flen (.length (clojure.java.io/file path))
         skip (- flen tail)
-        log-dir (File. root-dir)
+        log-dir (.getCanonicalFile (File. root-dir))
         log-file (File. path)]
     (if (= log-dir (.getParentFile log-file))
-    (with-open [input (clojure.java.io/input-stream path)
-                output (java.io.ByteArrayOutputStream.)]
-      (if (> skip 0) (.skip input skip))
-        (let [buffer (make-array Byte/TYPE 1024)]
-          (loop []
-            (let [size (.read input buffer)]
-              (when (and (pos? size) (< (.size output) tail))
-                (do (.write output buffer 0 size)
-                    (recur))))))
+      (with-open [input (clojure.java.io/input-stream path)
+                  output (java.io.ByteArrayOutputStream.)]
+        (if (> skip 0) (.skip input skip))
+          (let [buffer (make-array Byte/TYPE 1024)]
+            (loop []
+              (let [size (.read input buffer)]
+                (when (and (pos? size) (< (.size output) tail))
+                  (do (.write output buffer 0 size)
+                      (recur))))))
         (.toString output)) "File not found")
     ))