diff options
| author | Nils Schwabe | 2014-06-23 15:12:57 +0200 |
|---|---|---|
| committer | Nils Schwabe | 2014-06-23 15:12:57 +0200 |
| commit | e37fd784eefe513eda7ab946dcf92b8e8fe1b8a6 (patch) | |
| tree | 7f7fe48fd392223ee63166467f6342553b2ddc77 /src/main/java/org/openslx/imagemaster/server | |
| parent | Forgot thrift file (diff) | |
| download | masterserver-e37fd784eefe513eda7ab946dcf92b8e8fe1b8a6.tar.gz masterserver-e37fd784eefe513eda7ab946dcf92b8e8fe1b8a6.tar.xz masterserver-e37fd784eefe513eda7ab946dcf92b8e8fe1b8a6.zip | |
Fix some issues with the ftp connection and the ftp user management
Remove some not needed imports from various files
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/server')
| -rw-r--r-- | src/main/java/org/openslx/imagemaster/server/ApiServer.java | 10 |
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 ); |
