summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2015-08-28 16:06:19 +0200
committerJonathan Bauer2015-08-28 16:06:19 +0200
commitcc1b9a0488c4e6dda784a4db90202a709c4980ae (patch)
treedb581ac070f5807d70f7aae2f1d5c76d8073cde7
parent[client] version check in initSession (diff)
parent[client] Check space on disk and satellite before down/- uploading. (diff)
downloadtutor-module-cc1b9a0488c4e6dda784a4db90202a709c4980ae.tar.gz
tutor-module-cc1b9a0488c4e6dda784a4db90202a709c4980ae.tar.xz
tutor-module-cc1b9a0488c4e6dda784a4db90202a709c4980ae.zip
Merge branch 'v1.1' of git.openslx.org:openslx-ng/tutor-module into v1.1
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java28
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 2da68dec..dddb6de5 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
@@ -43,6 +43,7 @@ import org.openslx.dozmod.gui.MainWindow;
import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.gui.helper.QFileChooser;
import org.openslx.sat.thrift.version.Version;
+import org.openslx.dozmod.util.FormatHelper;
import org.openslx.thrifthelper.ThriftManager;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;
@@ -230,6 +231,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(
@@ -298,7 +308,7 @@ public class ThriftActions {
}
return new InitUploadStatus(uploadTask, hashGen);
}
-
+
/**
* GUI-BLOCKING
* Gives user feedback
@@ -337,14 +347,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,
@@ -356,6 +366,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() {
@@ -460,7 +476,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 {
@@ -594,7 +610,7 @@ public class ThriftActions {
lecturesToBeDeleted.add(lecture);
}
}
-
+
} catch (TException e) {
ThriftError.showMessage(frame, LOGGER, e, "Fehler");
return;
@@ -782,7 +798,7 @@ public class ThriftActions {
}
return lecture;
}
-
+
/**
* GUI-BLOCKING
* Updates the lecture with given lectureId to the given lecture