diff options
author | Steffen Ritter | 2023-06-02 15:46:50 +0200 |
---|---|---|
committer | Steffen Ritter | 2023-06-02 15:56:39 +0200 |
commit | f500d1a5cf47230a26a4e2b2fe124815052578da (patch) | |
tree | b3299f7115eba5e8355068b3d8bbcf81b57d5c3b /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java | |
parent | [server] Fix possible NPE (diff) | |
download | tutor-module-f500d1a5cf47230a26a4e2b2fe124815052578da.tar.gz tutor-module-f500d1a5cf47230a26a4e2b2fe124815052578da.tar.xz tutor-module-f500d1a5cf47230a26a4e2b2fe124815052578da.zip |
[server] Use upload token as filename for ongoing uploads
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 | 9 |
1 files changed, 5 insertions, 4 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; } |