From 034e4bc7cd5ca3271e59ebdba1b25beb37b4b73c Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Tue, 28 May 2013 07:39:01 -0400 Subject: [PATCH] Enabled SparkleShare client menu using 1.1.0 invite handler redesign --- src/main/java/com/gitblit/GitBlit.java | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java index 93293d8..081b74a 100644 --- a/src/main/java/com/gitblit/GitBlit.java +++ b/src/main/java/com/gitblit/GitBlit.java @@ -128,7 +128,6 @@ import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.WicketUtils; import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import com.google.gson.JsonIOException; import com.google.gson.JsonSyntaxException; import com.google.gson.reflect.TypeToken; @@ -615,7 +614,7 @@ Type type = new TypeToken<Collection<GitClientApplication>>() { }.getType(); InputStreamReader reader = new InputStreamReader(is); - Gson gson = new GsonBuilder().create(); + Gson gson = JsonUtils.gson(); Collection<GitClientApplication> links = gson.fromJson(reader, type); return links; } catch (JsonIOException e) { @@ -1365,11 +1364,12 @@ // optionally (re)calculate repository sizes if (getBoolean(Keys.web.showRepositorySizes, true)) { + ByteFormat byteFormat = new ByteFormat(); msg = "{0} repositories identified with calculated folder sizes in {1} msecs"; for (String repository : repositories) { RepositoryModel model = getRepositoryModel(repository); if (!model.skipSizeCalculation) { - calculateSize(model); + model.size = byteFormat.format(calculateSize(model)); } } } else { @@ -1560,6 +1560,10 @@ } model.lastChange = JGitUtils.getLastChange(r); + if (!model.skipSizeCalculation) { + ByteFormat byteFormat = new ByteFormat(); + model.size = byteFormat.format(calculateSize(model)); + } } r.close(); @@ -3509,6 +3513,8 @@ // extract the resource to the directory if it does not exist File f = new File(toDir, resource.substring(path.length())); if (!f.exists()) { + InputStream is = null; + OutputStream os = null; try { if (resource.charAt(resource.length() - 1) == '/') { // directory @@ -3517,20 +3523,33 @@ } else { // file f.getParentFile().mkdirs(); - InputStream is = context.getResourceAsStream(resource); - OutputStream os = new FileOutputStream(f); + is = context.getResourceAsStream(resource); + os = new FileOutputStream(f); byte [] buffer = new byte[4096]; int len = 0; while ((len = is.read(buffer)) > -1) { os.write(buffer, 0, len); } - is.close(); - os.close(); } } catch (FileNotFoundException e) { logger.error("Failed to find resource \"" + resource + "\"", e); } catch (IOException e) { logger.error("Failed to copy resource \"" + resource + "\" to " + f, e); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + // ignore + } + } + if (os != null) { + try { + os.close(); + } catch (IOException e) { + // ignore + } + } } } } -- Gitblit v1.9.1