1515 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616 GNU General Public License for more details.
1717
18- You should have received a copy of the GNU General Public License along
18+ You should have received a copy of the GNU General Public License along
1919 with this program; if not, write to the Free Software Foundation, Inc.
2020 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2121*/
@@ -43,7 +43,7 @@ public class ContributionManager {
4343 /**
4444 * Blocks until the file is downloaded or an error occurs. Returns true if the
4545 * file was successfully downloaded, false otherwise.
46- *
46+ *
4747 * @param source
4848 * the URL of the file to download
4949 * @param dest
@@ -67,17 +67,18 @@ static boolean download(URL source, File dest, ProgressMonitor progress) {
6767 conn .setReadTimeout (60 * 1000 );
6868 conn .setRequestMethod ("GET" );
6969 conn .connect ();
70-
70+
7171 if (progress != null ) {
7272 // TODO this is often -1, may need to set progress to indeterminate
7373 int fileSize = conn .getContentLength ();
74+ progress .max = fileSize ;
7475// System.out.println("file size is " + fileSize);
75- progress .startTask (Language .text ("contrib.progress.downloading" ), fileSize );
76+ progress .startTask (Language .text ("contrib.progress.downloading" ), fileSize );
7677 }
77-
78+
7879 InputStream in = conn .getInputStream ();
7980 FileOutputStream out = new FileOutputStream (dest );
80-
81+
8182 byte [] b = new byte [8192 ];
8283 int amount ;
8384 if (progress != null ) {
@@ -95,7 +96,7 @@ static boolean download(URL source, File dest, ProgressMonitor progress) {
9596 out .flush ();
9697 out .close ();
9798 success = true ;
98-
99+
99100 } catch (SocketTimeoutException ste ) {
100101 if (progress != null ) {
101102 progress .error (ste );
@@ -106,15 +107,15 @@ static boolean download(URL source, File dest, ProgressMonitor progress) {
106107 progress .error (ioe );
107108 progress .cancel ();
108109 }
109- // Hiding stack trace. An error has been shown where needed.
110+ // Hiding stack trace. An error has been shown where needed.
110111// ioe.printStackTrace();
111112 }
112113 if (progress != null )
113114 progress .finished ();
114115 return success ;
115116 }
116117
117-
118+
118119 /**
119120 * Non-blocking call to download and install a contribution in a new thread.
120121 *
@@ -143,10 +144,10 @@ public void run() {
143144
144145 try {
145146 download (url , contribZip , downloadProgress );
146-
147+
147148 if (!downloadProgress .isCanceled () && !downloadProgress .isError ()) {
148149 installProgress .startTask (Language .text ("contrib.progress.installing" ), ProgressMonitor .UNKNOWN );
149- LocalContribution contribution =
150+ LocalContribution contribution =
150151 ad .install (editor .getBase (), contribZip , false , status );
151152
152153 if (contribution != null ) {
@@ -196,11 +197,11 @@ public void run() {
196197
197198 /**
198199 * Non-blocking call to download and install a contribution in a new thread.
199- *
200+ *
200201 * @param url
201202 * Direct link to the contribution.
202203 * @param ad
203- * The AvailableContribution to be downloaded and installed.
204+ * The AvailableContribution to be downloaded and installed.
204205 */
205206 static void downloadAndInstallOnStartup (final Base base , final URL url ,
206207 final AvailableContribution ad ) {
@@ -215,7 +216,7 @@ public void run() {
215216
216217 try {
217218 download (url , contribZip , null );
218-
219+
219220 LocalContribution contribution = ad .install (base , contribZip ,
220221 false , null );
221222
@@ -233,7 +234,7 @@ public void run() {
233234 }
234235
235236 contribZip .delete ();
236-
237+
237238 handleUpdateFailedMarkers (ad , filename .substring (0 , filename .lastIndexOf ('.' )));
238239
239240 } catch (Exception e ) {
@@ -353,27 +354,27 @@ static public String getFileName(File libFile) {
353354
354355 return fileName ;
355356 }
356-
357-
358- /**
357+
358+
359+ /**
359360 * Called by Base to clean up entries previously marked for deletion
360361 * and remove any "requires restart" flags.
361362 * Also updates all entries previously marked for update.
362363 */
363364 static public void cleanup (final Base base ) throws Exception {
364-
365+
365366 deleteTemp (Base .getSketchbookModesFolder ());
366367 deleteTemp (Base .getSketchbookToolsFolder ());
367-
368+
368369 deleteFlagged (Base .getSketchbookLibrariesFolder ());
369370 deleteFlagged (Base .getSketchbookModesFolder ());
370371 deleteFlagged (Base .getSketchbookToolsFolder ());
371-
372+
372373 installPreviouslyFailed (base , Base .getSketchbookModesFolder ());
373374 updateFlagged (base , Base .getSketchbookModesFolder ());
374-
375+
375376 updateFlagged (base , Base .getSketchbookToolsFolder ());
376-
377+
377378 SwingWorker s = new SwingWorker <Void , Void >() {
378379
379380 @ Override
@@ -389,8 +390,8 @@ protected Void doInBackground() throws Exception {
389390 };
390391 s .execute ();
391392
392-
393-
393+
394+
394395 clearRestartFlags (Base .getSketchbookModesFolder ());
395396 clearRestartFlags (Base .getSketchbookToolsFolder ());
396397 }
@@ -400,7 +401,7 @@ protected Void doInBackground() throws Exception {
400401 * Deletes the icky tmp folders that were left over from installs and updates
401402 * in the previous run of Processing. Needed to be called only on the tools
402403 * and modes sketchbook folders.
403- *
404+ *
404405 * @param root
405406 */
406407 static private void deleteTemp (File root ) {
@@ -421,7 +422,7 @@ static private void deleteTemp(File root) {
421422
422423 /**
423424 * Deletes all the modes/tools/libs that are flagged for removal.
424- *
425+ *
425426 * @param root
426427 * @throws Exception
427428 */
@@ -436,12 +437,12 @@ public boolean accept(File folder) {
436437 Base .removeDir (folder );
437438 }
438439 }
439-
440-
440+
441+
441442 /**
442443 * Installs all the modes/tools whose installation failed during an
443444 * auto-update the previous time Processing was started up.
444- *
445+ *
445446 * @param base
446447 * @param root
447448 * @throws Exception
@@ -470,7 +471,7 @@ public boolean accept(File folder) {
470471
471472 /**
472473 * Updates all the flagged modes/tools.
473- *
474+ *
474475 * @param base
475476 * @param root
476477 * @throws Exception
@@ -502,24 +503,24 @@ else if (type.equalsIgnoreCase("libraries")) //putting this here, just in case
502503 updateContribsNames .add (properties .get ("name" ));
503504 Base .removeDir (folder );
504505 }
505-
506+
506507 Iterator <AvailableContribution > iter = contribListing .advertisedContributions .iterator ();
507508 while (iter .hasNext ()) {
508509 AvailableContribution availableContribs = iter .next ();
509510 if (updateContribsNames .contains (availableContribs .getName ())) {
510511 updateContribsList .add (availableContribs );
511512 }
512513 }
513-
514+
514515 Iterator <AvailableContribution > iter2 = updateContribsList .iterator ();
515516 while (iter2 .hasNext ()) {
516517 AvailableContribution contribToUpdate = iter2 .next ();
517518 installOnStartUp (base , contribToUpdate );
518519 contribListing .replaceContribution (contribToUpdate , contribToUpdate );
519520 }
520521 }
521-
522-
522+
523+
523524 static private void installOnStartUp (final Base base , final AvailableContribution availableContrib ) {
524525 if (availableContrib .link == null ) {
525526 Base .showWarning (Language .interpolate ("contrib.errors.update_on_restart_failed" , availableContrib .getName ()),
@@ -528,16 +529,16 @@ static private void installOnStartUp(final Base base, final AvailableContributio
528529 }
529530 try {
530531 URL downloadUrl = new URL (availableContrib .link );
531-
532+
532533 ContributionManager .downloadAndInstallOnStartup (base , downloadUrl , availableContrib );
533-
534+
534535 } catch (MalformedURLException e ) {
535536 Base .showWarning (Language .interpolate ("contrib.errors.update_on_restart_failed" , availableContrib .getName ()),
536537 Language .text ("contrib.errors.malformed_url" ), e );
537538 }
538539 }
539-
540-
540+
541+
541542 static private void clearRestartFlags (File root ) throws Exception {
542543 File [] folderList = root .listFiles (new FileFilter () {
543544 public boolean accept (File folder ) {
0 commit comments