From 5177ee3182241b546d17e694100a6990643c4824 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 1 Sep 2016 16:34:09 +0200 Subject: [LinkConfigTgz] Passing empty target means remove link --- .../openslx/taskmanager/tasks/LinkConfigTgz.java | 28 +++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java b/src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java index bd770d5..7816247 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java +++ b/src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java @@ -27,10 +27,14 @@ public class LinkConfigTgz extends AbstractTask protected boolean initTask() { this.setStatusObject( status ); - this.destination = FilenameUtils.normalize( this.destination ); - if ( this.destination == null || !Util.startsWith( this.destination, ALLOWED_DIRS ) ) { - status.error = "File not in allowed directory"; - return false; + if ( this.destination != null && !this.destination.isEmpty() ) { + this.destination = FilenameUtils.normalize( this.destination ); + if ( !Util.startsWith( this.destination, ALLOWED_DIRS ) ) { + status.error = "File not in allowed directory"; + return false; + } + } else { + this.destination = null; } return true; } @@ -40,17 +44,19 @@ public class LinkConfigTgz extends AbstractTask { try { Files.createDirectory( Paths.get( "/srv/openslx/www/boot/default" ) ); - } catch (Exception e) { + } catch ( Exception e ) { } try { FileUtils.deleteQuietly( new File( "/srv/openslx/www/boot/default/config.tgz" ) ); - } catch (Exception e) { + } catch ( Exception e ) { } - try { - Files.createSymbolicLink( Paths.get( "/srv/openslx/www/boot/default/config.tgz" ), Paths.get( this.destination ) ); - } catch ( IOException e ) { - status.error = e.toString(); - return false; + if ( this.destination != null ) { + try { + Files.createSymbolicLink( Paths.get( "/srv/openslx/www/boot/default/config.tgz" ), Paths.get( this.destination ) ); + } catch ( IOException e ) { + status.error = e.toString(); + return false; + } } return true; } -- cgit v1.2.3-55-g7522