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/fileserv/FileServer.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/fileserv/FileServer.java')
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java index 656a515b..b1466b5c 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java @@ -236,7 +236,7 @@ public class FileServer implements IncomingEvent { throw new TTransferRejectedException(errorMessage); } String key = UUID.randomUUID().toString(); - OutgoingDataTransfer transfer = new OutgoingDataTransfer(key, srcFile, getPlainPort(), getSslPort()); + OutgoingDataTransfer transfer = new OutgoingDataTransfer(key, srcFile, getPlainPort(), getSslPort(), localImageData.imageVersionId); downloads.put(key, transfer); return transfer; } @@ -244,6 +244,28 @@ public class FileServer implements IncomingEvent { public Status getStatus() { return new Status(); } + + /** + * Check whether the given imageVersionId refers to an active transfer. + */ + public boolean isActiveTransfer(String baseId, String versionId) { + long now = System.currentTimeMillis(); + if (versionId != null) { + for (OutgoingDataTransfer odt : downloads.values()) { + if (versionId != null && versionId.equals(odt.getVersionId()) && !odt.isComplete(now) && odt.isActive()) + return true; + } + } + for (IncomingDataTransfer idt : uploads.values()) { + if (idt.isComplete(now) || !idt.isActive()) + continue; + if (versionId != null && versionId.equals(idt.getVersionId())) + return true; + if (baseId != null && baseId.equals(idt.getBaseId())) + return true; + } + return false; + } class Status { public final int activeUploads; |