Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Issue #27
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcasters committed Feb 5, 2019
1 parent 07d7052 commit 9822b96
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main/java/org/kettle/env/config/EnvironmentConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ public EnvironmentConfig() {
openingLastEnvironmentAtStartup = false;
}

public EnvironmentConfig(EnvironmentConfig c) {
name = c.name;
lastUsedEnvironment = c.lastUsedEnvironment;
enabled = c.enabled;
openingLastEnvironmentAtStartup = c.openingLastEnvironmentAtStartup;
}

/**
* Gets name
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,32 @@ public static void initialize( IMetaStore environmentMetaStore ) throws MetaStor
}

public static void saveConfig() throws MetaStoreException {
configSingleton.configFactory.saveElement( configSingleton.config );

MetaStoreFactory<EnvironmentConfig> factory = configSingleton.configFactory;

// See if the config is already available...
//
EnvironmentConfig backupConfig = factory.loadElement( configSingleton.config.getName() );
if (backupConfig!=null) {
String backupName = backupConfig.getName()+"_backup";
backupConfig.setName(backupName);
// Delete the backup to make sure...
//
if (factory.loadElement( backupName)!=null) {
factory.deleteElement( backupName);
}
// Save the backup
//
factory.saveElement( backupConfig );

// Now delete the existing element...
//
factory.deleteElement( configSingleton.config.getName() );
}

// Now save the element.
//
factory.saveElement( configSingleton.config );
}

public static EnvironmentConfig getConfig() {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/kettle/env/util/EnvironmentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ private static boolean isInSubDirectory( FileObject file, FileObject directory )
return true;
}

if (filePath.startsWith( directoryPath )) {
return true;
}

FileObject parent = file.getParent();
if ( parent != null && isInSubDirectory( parent, directory ) ) {
return true;
Expand Down

0 comments on commit 9822b96

Please sign in to comment.