diff options
author | Stephan Schwaer | 2015-08-28 15:52:58 +0200 |
---|---|---|
committer | Stephan Schwaer | 2015-08-28 15:52:58 +0200 |
commit | 8895dd6fb5d02fe47bf8a611f4d7dffaf83afab4 (patch) | |
tree | 55ae7c1c3eaf8af36417173700897d9064f2ce67 /dozentenmodul/src/main/java/org/openslx | |
parent | Merge branch 'v1.1' of git.openslx.org:openslx-ng/tutor-module into v1.1 (diff) | |
download | tutor-module-8895dd6fb5d02fe47bf8a611f4d7dffaf83afab4.tar.gz tutor-module-8895dd6fb5d02fe47bf8a611f4d7dffaf83afab4.tar.xz tutor-module-8895dd6fb5d02fe47bf8a611f4d7dffaf83afab4.zip |
[client] Check space on disk and satellite before down/- uploading.
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java index ddac7c67..98eb3eaa 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java @@ -42,6 +42,7 @@ import org.openslx.dozmod.gui.Gui.GuiCallable; import org.openslx.dozmod.gui.MainWindow; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.helper.QFileChooser; +import org.openslx.dozmod.util.FormatHelper; import org.openslx.thrifthelper.ThriftManager; import org.openslx.util.QuickTimer; import org.openslx.util.QuickTimer.Task; @@ -212,6 +213,15 @@ public class ThriftActions { public static TransferInformation requestVersionUpload(final Frame frame, final String imageBaseId, final long fileSize, final List<ByteBuffer> blockHashes, final ByteBuffer machineDescription) { + try { + if (ThriftManager.getSatClient().getStatus().getAvailableStorageBytes() < fileSize){ + Gui.showMessageBox(frame, "Nicht genügend Speicherplatz Satelliten. Löschen Sie nicht verwendete Imageversionen oder kontaktieren sie den Administrator.", MessageType.ERROR, LOGGER, null); + return null; + } + } catch (TException e1) { + ThriftError.showMessage(frame, LOGGER, e1, "Konnte Status des Satelliten nicht abfragen!"); + return null; + } TransferInformation ti = null; try { ti = ThriftManager.getSatClient().requestImageVersionUpload( @@ -280,7 +290,7 @@ public class ThriftActions { } return new InitUploadStatus(uploadTask, hashGen); } - + /** * GUI-BLOCKING * Gives user feedback @@ -319,14 +329,14 @@ public class ThriftActions { /** * NON-BLOCKING - * Initializes the download of the given imageVersionId saving it to the given + * Initialises the download of the given imageVersionId saving it to the given * imageName * * @param frame caller of this method * @param imageVersionId image version id to download * @param imageName destination file name * @param virtualizerId id of the virtualizer - * @param imageSize size in bytes of the image to be downloaded + * @param imageSize size in bytes of the image to download * @param callback callback function to return status of this operation to the GUI */ public static void initDownload(final Frame frame, final String imageVersionId, final String imageName, @@ -338,6 +348,12 @@ public class ThriftActions { if (action != JFileChooser.APPROVE_OPTION || file == null) return; + // Check the free space on disk + if(file.getUsableSpace() < imageSize) { + Gui.showMessageBox(frame, "Nicht genügend Speicherplatz im ausgewählten Verzeichnis verfügbar.", MessageType.ERROR, LOGGER, null); + return; + } + QuickTimer.scheduleOnce(new Task() { @Override public void fire() { @@ -442,7 +458,7 @@ public class ThriftActions { public interface ImageMetaCallback { void fetchedImageDetails(ImageDetailsRead details, Map<String, ImagePermissions> permissions); } - + public static ImageDetailsRead getImageDetails(final Frame frame, final String imageBaseId) { ImageDetailsRead details = null; try { @@ -576,7 +592,7 @@ public class ThriftActions { lecturesToBeDeleted.add(lecture); } } - + } catch (TException e) { ThriftError.showMessage(frame, LOGGER, e, "Fehler"); return; @@ -764,7 +780,7 @@ public class ThriftActions { } return lecture; } - + /** * GUI-BLOCKING * Updates the lecture with given lectureId to the given lecture |