summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2016-09-01 16:34:09 +0200
committerSimon Rettberg2016-09-01 16:34:09 +0200
commit5177ee3182241b546d17e694100a6990643c4824 (patch)
tree0163cf352d09d8185d9065dcb655cd53473d36af /src
parentsystem-restore: Support new webif (modularized) (diff)
downloadtmlite-bwlp-5177ee3182241b546d17e694100a6990643c4824.tar.gz
tmlite-bwlp-5177ee3182241b546d17e694100a6990643c4824.tar.xz
tmlite-bwlp-5177ee3182241b546d17e694100a6990643c4824.zip
[LinkConfigTgz] Passing empty target means remove link
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/openslx/taskmanager/tasks/LinkConfigTgz.java28
1 files 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;
}