diff options
| author | Nino Breuer | 2014-11-03 09:17:29 +0100 |
|---|---|---|
| committer | Nino Breuer | 2014-11-03 09:17:29 +0100 |
| commit | 4a078e9847b348441fdd7a36b558e107a7280ff0 (patch) | |
| tree | 8ad894376343bd00b46bceb113ace5ce1e02737c /dozentenmodul/src/main/java/ftp/UploadTask.java | |
| parent | v (diff) | |
| parent | • fixed bug which caused search guis to be closed when pressing enter in se... (diff) | |
| download | tutor-module-4a078e9847b348441fdd7a36b558e107a7280ff0.tar.gz tutor-module-4a078e9847b348441fdd7a36b558e107a7280ff0.tar.xz tutor-module-4a078e9847b348441fdd7a36b558e107a7280ff0.zip | |
Merge branch 'master' of ssh://git.openslx.org/openslx-ng/tutor-module
Conflicts:
dozentenmodulserver/src/main/java/sql/SQL.java
• Note: manual merge
Diffstat (limited to 'dozentenmodul/src/main/java/ftp/UploadTask.java')
| -rw-r--r-- | dozentenmodul/src/main/java/ftp/UploadTask.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/dozentenmodul/src/main/java/ftp/UploadTask.java b/dozentenmodul/src/main/java/ftp/UploadTask.java index 68af1f3c..2579b125 100644 --- a/dozentenmodul/src/main/java/ftp/UploadTask.java +++ b/dozentenmodul/src/main/java/ftp/UploadTask.java @@ -24,9 +24,7 @@ public class UploadTask extends SwingWorker<Void, Void> { */ private final static Logger LOGGER = Logger.getLogger(UploadTask.class); - // 8MB buffer private static final int BUFFER_SIZE = 1024 * 1024; - private static final double UPDATE_INTERVAL_SECONDS = 0.6; private static final double UPDATE_INTERVAL_MS = UPDATE_INTERVAL_SECONDS * 1000; private static final double BYTES_PER_MIB = 1024 * 1024; @@ -60,11 +58,15 @@ public class UploadTask extends SwingWorker<Void, Void> { util.connect(); util.uploadFile(uploadFile, destDir); - FileInputStream inputStream = new FileInputStream(uploadFile); + // show filesize in the GUI long fileSize = uploadFile.length(); Image.image.setFilesize(fileSize); firePropertyChange("filesize", 0, fileSize); + // prepare input stream + FileInputStream inputStream = new FileInputStream(uploadFile); + + // initialize the counters needed for speed calculations percentCompleted = 0; byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = -1; @@ -88,11 +90,12 @@ public class UploadTask extends SwingWorker<Void, Void> { currentBytes = 0; } } + // finalize the upload by updating the progress bar one last time + // (in case we didn't get to do it because of the time interval) percentCompleted = (int) ((totalBytesRead * 100) / fileSize); setProgress(percentCompleted); firePropertyChange("bytesread", 0, totalBytesRead); inputStream.close(); - util.finish(); } catch (FTPException ex) { JOptionPane.showMessageDialog(null, |
