From 8895dd6fb5d02fe47bf8a611f4d7dffaf83afab4 Mon Sep 17 00:00:00 2001 From: Stephan Schwaer Date: Fri, 28 Aug 2015 15:52:58 +0200 Subject: [client] Check space on disk and satellite before down/- uploading. --- .../org/openslx/dozmod/thrift/ThriftActions.java | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'dozentenmodul/src/main/java/org/openslx') 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 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 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 -- cgit v1.2.3-55-g7522