diff options
author | Simon Rettberg | 2023-07-27 15:58:59 +0200 |
---|---|---|
committer | Simon Rettberg | 2023-07-27 15:58:59 +0200 |
commit | 59f45d869f02226597c00ccc55f3e1a0b1df078f (patch) | |
tree | b2b35e2074f9bae6880cfc5680f630c20ab8d9f8 /dozentenmodul | |
parent | [client] bwIDM -> DFN-AAI (diff) | |
download | tutor-module-59f45d869f02226597c00ccc55f3e1a0b1df078f.tar.gz tutor-module-59f45d869f02226597c00ccc55f3e1a0b1df078f.tar.xz tutor-module-59f45d869f02226597c00ccc55f3e1a0b1df078f.zip |
[client] Check if VM is suspended before upload
Diffstat (limited to 'dozentenmodul')
3 files changed, 20 insertions, 8 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java index aacb0d31..7afeb9c7 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java @@ -38,6 +38,7 @@ import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.dozmod.util.FormatHelper; import org.openslx.sat.thrift.version.Feature; import org.openslx.thrifthelper.TConst; +import org.openslx.util.Util; import org.openslx.virtualization.configuration.VirtualizationConfigurationVmware; import org.openslx.virtualization.configuration.data.ConfigurationDataDozModClientToDozModServer; import org.openslx.virtualization.configuration.logic.ConfigurationLogicDozModClientToDozModServer; @@ -383,11 +384,18 @@ public class ImageUploadPage extends ImageUploadPageLayout { setPageComplete(true); } + /** + * Check if a lock file exists and ask the user if they want to abort the upload. + * @return true if the upload is to be aborted + */ private boolean askCancelLockFile(String... lockFiles) { for (String lockFile : lockFiles) { + if (Util.isEmptyString(lockFile)) + continue; File file = new File(lockFile); if (!file.exists()) continue; + // Return true if NO was selected. Question is "Continue anyways?" return !Gui.showMessageBox(this, I18n.PAGE.getString("ImageUpload.Message.yesNo.cancelLockFile"), MessageType.QUESTION_YESNO, null, null); } @@ -410,9 +418,13 @@ public class ImageUploadPage extends ImageUploadPageLayout { @Override protected boolean wantNextOrFinish() { - // Check for vmware player lock files - warn user if found, might corrupt upload - if (askCancelLockFile(state.descriptionFile.getAbsolutePath() + ".lck", - state.diskFile.getAbsolutePath() + ".lck")) { + // Check for vmware player lock/suspend files - warn user if found, might corrupt upload + String suspendedFile = state.virtualizationConfig.getSuspendedFile(); + if (!Util.isEmptyString(suspendedFile)) { + suspendedFile = state.descriptionFile.getParent() + File.separatorChar + suspendedFile; + } + if (askCancelLockFile(state.descriptionFile.getPath() + ".lck", + state.diskFile.getPath() + ".lck", suspendedFile)) { setErrorMessage(I18n.PAGE.getString("ImageUpload.WizardPage.errorMessage.cancelLockFile")); return false; } diff --git a/dozentenmodul/src/main/properties/i18n/page.properties b/dozentenmodul/src/main/properties/i18n/page.properties index 03c29cea..2c3bae75 100644 --- a/dozentenmodul/src/main/properties/i18n/page.properties +++ b/dozentenmodul/src/main/properties/i18n/page.properties @@ -28,9 +28,9 @@ ImageUpload.WizardPage.errorMessage.diskImageStandalone=The disk image file of t ImageUpload.Message.warning.diskImageStandalone=The format of the virtual hard disk associated with this\n VM is not \ standalone. Please convert the VM\n\into a standalone (single-file) format. ImageUpload.WizardPage.description=You can now start the upload. -ImageUpload.Message.yesNo.cancelLockFile=The selected VM seems to be still in use. Please shut down the VM\n\ - before uploading and close the VMware Player, otherwise\n\ - the VM may be damaged after uploading.\n\n\ +ImageUpload.Message.yesNo.cancelLockFile=The selected VM seems to be still in use, or was suspended. Please shut down the VM\n\ + properly and close VMware/VirtualBox, otherwise\n\ + the VM may be broken after uploading.\n\n\ Do you want to ignore this warning and continue anyway?\n\ (You should be sure what you are doing if you choose ''Yes'' here.) ImageUpload.WizardPage.errorMessage.cancelLockFile=The selected VM is still in use diff --git a/dozentenmodul/src/main/properties/i18n/page_de_DE.properties b/dozentenmodul/src/main/properties/i18n/page_de_DE.properties index 5fa49955..065e929a 100644 --- a/dozentenmodul/src/main/properties/i18n/page_de_DE.properties +++ b/dozentenmodul/src/main/properties/i18n/page_de_DE.properties @@ -29,8 +29,8 @@ ImageUpload.Message.warning.diskImageStandalone=Die zu dieser VM gehörige virtu eigenständiges\nFormat auf. Bitte konvertieren Sie die VM in ein eigenständiges\n (Einzeldatei-) Format. ImageUpload.Message.warning.virtConfigNotValid=Die ausgewählte Konfigurationsdatei scheint Fehler zu enthalten. Trotzdem fortfahren? ImageUpload.WizardPage.description=Sie können jetzt den Upload starten. -ImageUpload.Message.yesNo.cancelLockFile=Die gewählte VM scheint noch in Verwendung zu sein. Bitte fahren Sie die VM\n\ - vor dem Hochladen herunter und schließen Sie den VMware Player, ansonsten\n\ +ImageUpload.Message.yesNo.cancelLockFile=Die gewählte VM scheint noch in Verwendung zu sein, oder wurde Suspended. Bitte fahren Sie die VM\n\ + vor dem Hochladen vollständig herunter und schließen Sie VMware/VirtualBox, ansonsten\n\ kann die VM nach dem Hochladen beschädigt sein.\n\n\ Möchten Sie diese Warnung ignorieren und trotzdem fortfahren?\n\ (Sie sollten sich sicher sein, was Sie tun, wenn Sie hier ''Ja'' wählen.) |