summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/imagemaster/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/server')
-rw-r--r--src/main/java/org/openslx/imagemaster/server/ApiServer.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/org/openslx/imagemaster/server/ApiServer.java b/src/main/java/org/openslx/imagemaster/server/ApiServer.java
index a36f201..52783d9 100644
--- a/src/main/java/org/openslx/imagemaster/server/ApiServer.java
+++ b/src/main/java/org/openslx/imagemaster/server/ApiServer.java
@@ -184,6 +184,10 @@ public class ApiServer
synchronized ( App.ftpServer.users ) {
if (!App.ftpServer.users.containsKey( ftpUser )) {
throw new ImageDataException( ImageDataError.UNKNOWN_IMAGE, "Image with this data was not submitted before." );
+ } else {
+ if ( App.ftpServer.users.get( ftpUser ).getMode() == MasterFtpServer.Mode.DOWNLOADING ) {
+ throw new ImageDataException( ImageDataError.UNKNOWN_IMAGE, "Your were downloading and not uploading." );
+ }
}
}
@@ -191,7 +195,7 @@ public class ApiServer
File userDirectory = new File( Globals.getPropertyString( Globals.PropString.FTPBASEDIR ) + "/" + ftpUser );
File[] list = userDirectory.listFiles();
- if ( list.length != 1 ) {
+ if ( list == null || list.length != 1 ) {
// user uploaded too many files
return false;
}
@@ -218,7 +222,7 @@ public class ApiServer
if (image == null) throw new ImageDataException( ImageDataError.UNKNOWN_IMAGE, "No image found with uuid '" + uuid + "'");
- FtpCredentials ftpCredentials = App.ftpServer.addUser( serverSessionId, MasterFtpServer.Mode.DOWNLOADING, image.imagePath );
+ FtpCredentials ftpCredentials = App.ftpServer.addUser( serverSessionId, MasterFtpServer.Mode.DOWNLOADING, new File(image.imagePath).getName() );
// TODO: what is happening here?
if (ftpCredentials == null) return null;
@@ -231,6 +235,8 @@ public class ApiServer
if ( !App.ftpServer.users.containsKey( ftpUser ))
return false;
+ log.info( "User: '" + ftpUser + "' finished download and gets deleted." );
+
// download is done, user can be removed now
App.ftpServer.removeUser( ftpUser );