diff options
author | Simon Rettberg | 2019-10-21 16:59:32 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-10-21 17:08:16 +0200 |
commit | 535fc19e824abfe170b6fe03792519cb6e1105eb (patch) | |
tree | d6a5e7801eba3421f5f1bc40dcb17eabdb732ab3 /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java | |
parent | [client] Update virtualizer download link (diff) | |
download | tutor-module-535fc19e824abfe170b6fe03792519cb6e1105eb.tar.gz tutor-module-535fc19e824abfe170b6fe03792519cb6e1105eb.tar.xz tutor-module-535fc19e824abfe170b6fe03792519cb6e1105eb.zip |
[server] Disallow deleting busy images, fix multiple clones from master
Deleting images that are currently being up- or downloaded would create
some confusion server-side, so disallow this.
We accidentally didn't use the image version id as the transfer id for
downloads from the master server; fix that so that triggering the
download of the same image multiple times won't actually download the
same image multiple times.
Closes #3651
Diffstat (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java')
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java index a4c033cc..06c1e5a7 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java @@ -394,6 +394,9 @@ public class ServerHandler implements SatelliteServer.Iface { public void deleteImageVersion(String userToken, String imageVersionId) throws TAuthorizationException, TNotFoundException, TInvocationException { UserInfo user = SessionManager.getOrFail(userToken); + if (FileServer.instance().isActiveTransfer(null, imageVersionId) + || SyncTransferHandler.isActiveTransfer(null, imageVersionId)) + throw new TInvocationException(InvocationError.INVALID_DATA, "Image is currently in use"); if (!FileSystem.waitForStorage()) throw new TInvocationException(InvocationError.INTERNAL_SERVER_ERROR, "VM storage not mounted"); User.canDeleteImageVersionOrFail(user, imageVersionId); @@ -415,6 +418,9 @@ public class ServerHandler implements SatelliteServer.Iface { public void deleteImageBase(String userToken, String imageBaseId) throws TAuthorizationException, TNotFoundException, TInvocationException { UserInfo user = SessionManager.getOrFail(userToken); + if (FileServer.instance().isActiveTransfer(imageBaseId, null) + || SyncTransferHandler.isActiveTransfer(imageBaseId, null)) + throw new TInvocationException(InvocationError.INVALID_DATA, "Image is currently in use"); ImageDetailsRead imageDetails; try { imageDetails = DbImage.getImageDetails(user, imageBaseId); @@ -426,6 +432,9 @@ public class ServerHandler implements SatelliteServer.Iface { int index = 0; for (ImageVersionDetails version : imageDetails.versions) { if (version.versionId != null) { + if (FileServer.instance().isActiveTransfer(null, version.versionId) + || SyncTransferHandler.isActiveTransfer(null, version.versionId)) + throw new TInvocationException(InvocationError.INVALID_DATA, "Image is currently in use"); ids[index++] = version.versionId; } } |