summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java9
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java2
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Formatter.java14
3 files changed, 20 insertions, 5 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 597e4306..04212c42 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
@@ -156,22 +156,23 @@ public class FileServer implements IncomingEvent {
+ "/" + Constants.MAX_UPLOADS + ").");
}
File destinationFile = null;
+ String uploadkey = UUID.randomUUID().toString();
do {
- destinationFile = Formatter.getTempImageName();
+ destinationFile = Formatter.getTempImageName(uploadkey);
} while (destinationFile.exists());
destinationFile.getParentFile().mkdirs();
- String key = UUID.randomUUID().toString();
IncomingDataTransfer upload;
try {
- upload = new IncomingDataTransfer(key, owner, image, destinationFile, fileSize, sha1Sums,
+ upload = new IncomingDataTransfer(uploadkey, owner, image, destinationFile, fileSize, sha1Sums,
machineDescription, false);
} catch (FileNotFoundException e) {
LOGGER.error("Could not open destination file for writing", e);
throw new TTransferRejectedException("Destination file not writable!");
}
- uploads.put(key, upload);
+ LOGGER.info(owner.getFirstName() + " " + owner.getLastName() + " (" + owner.getUserId() + ") started upload " + uploadkey + " of '" + image.getImageName() + "'");
+ uploads.put(uploadkey, upload);
return upload;
}
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 f2382d78..ad99b2cf 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
@@ -166,7 +166,7 @@ public class ServerHandler implements SatelliteServer.Iface {
public void cancelUpload(String uploadToken) {
IncomingDataTransfer upload = fileServer.getUploadByToken(uploadToken);
if (upload != null) {
- LOGGER.debug("User is cancelling upload " + uploadToken);
+ LOGGER.info("User is cancelling upload " + uploadToken);
upload.cancel();
}
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Formatter.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Formatter.java
index 268ceda1..0bdc0ab7 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Formatter.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Formatter.java
@@ -26,6 +26,20 @@ public class Formatter {
}
/**
+ * Generate a file name used for a virtual machine
+ * image that is currently uploading, but use a given
+ * string as part of the file name.
+ * String should be some random uuid to get a unique
+ * file name.
+ *
+ * @param s String to use as part of the filename
+ * @return Absolute path name of file
+ */
+ public static File getTempImageName(String s) {
+ return new File(Configuration.getCurrentVmStorePath(), s + Constants.INCOMPLETE_UPLOAD_SUFFIX);
+ }
+
+ /**
* Generate a file name for the given VM based on owner and display name.
*
* @param ts Timestamp of upload