From dd38c9066535ea8e5de80d893aaf48b0be498238 Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Fri, 19 Jul 2002 22:19:34 +0000 Subject: [PATCH] Don't notify observers when we reach 100% completeness until the streams are closed. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1597 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/resource/DownloadManager.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/resource/DownloadManager.java b/src/java/com/threerings/resource/DownloadManager.java index 6e71e2d3f..05aea8c89 100644 --- a/src/java/com/threerings/resource/DownloadManager.java +++ b/src/java/com/threerings/resource/DownloadManager.java @@ -1,5 +1,5 @@ // -// $Id: DownloadManager.java,v 1.1 2002/07/19 20:12:23 shaper Exp $ +// $Id: DownloadManager.java,v 1.2 2002/07/19 22:19:34 shaper Exp $ package com.threerings.resource; @@ -293,13 +293,24 @@ public class DownloadManager currentSize += read; int pctdone = (int)((currentSize / (float)totalSize) * 100f); complete = (pctdone >= 100); - obs.downloadProgress(pctdone); + // if we've finished downloading everything, hold off on + // notifying the observer until the streams are closed to + // ensure that any action the observer may take with respect + // to the downloaded files can be safely undertaken + if (!complete) { + obs.downloadProgress(pctdone); + } } // close the streams in.close(); out.close(); + if (complete) { + // let the observer know we're finished now that it's safe + obs.downloadProgress(100); + } + // if we have a last modified time, we want to adjust our cache // file accordingly if (desc.lastModified != 0) {