[java-identity-provider] branch main updated: Change logic to remove disabled files that haven't changed.
Scott Cantor
cantor.2 at osu.edu
Thu Sep 3 23:13:20 UTC 2020
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=c435221a728daab4be0f76c99d7f9ac041455b7f
The following commit(s) were added to refs/heads/main by this push:
new c435221a7 Change logic to remove disabled files that haven't changed.
c435221a7 is described below
commit c435221a728daab4be0f76c99d7f9ac041455b7f
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Sep 3 19:13:12 2020 -0400
Change logic to remove disabled files that haven't changed.
---
.../net/shibboleth/idp/module/AbstractIdPModule.java | 18 +++++++++++-------
.../java/net/shibboleth/idp/module/IdPModuleTest.java | 10 +---------
2 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java b/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java
index 8c9beb9fb..fc4a87de5 100644
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java
@@ -17,8 +17,6 @@
package net.shibboleth.idp.module;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -27,6 +25,7 @@ import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -185,8 +184,8 @@ public abstract class AbstractIdPModule implements IdPModule {
* @return true iff the resource has been changed
*/
public boolean hasChanged(@Nonnull final ModuleContext moduleContext) {
+
try (final InputStream dest = getDestinationStream(moduleContext)) {
-
if (dest != null) {
final byte[] destHash;
@@ -295,9 +294,14 @@ public abstract class AbstractIdPModule implements IdPModule {
*/
@Nullable private InputStream getDestinationStream(@Nonnull final ModuleContext moduleContext)
throws IOException {
- final File destFile = moduleContext.getIdPHome().resolve(destination).toFile();
- if (destFile.exists() && destFile.isFile() && destFile.canRead()) {
- return new FileInputStream(destFile);
+
+ final Path destPath = moduleContext.getIdPHome().resolve(destination);
+ if (Files.exists(destPath)) {
+ try {
+ return Files.newInputStream(destPath, StandardOpenOption.READ);
+ } catch (final IOException e) {
+ log.error("Module {} unable to read destination resource {}", getId(), destPath, e);
+ }
}
return null;
@@ -365,7 +369,7 @@ public abstract class AbstractIdPModule implements IdPModule {
log.debug("Module {} resolved resource destination {}", getId(), resolved);
if (Files.exists(resolved)) {
try {
- if (clean) {
+ if (clean || !hasChanged(moduleContext)) {
log.info("Module {} removing resource {}", getId(), resolved);
Files.delete(resolved);
} else {
diff --git a/idp-admin-api/src/test/java/net/shibboleth/idp/module/IdPModuleTest.java b/idp-admin-api/src/test/java/net/shibboleth/idp/module/IdPModuleTest.java
index 75a02ee78..41fc4d91f 100644
--- a/idp-admin-api/src/test/java/net/shibboleth/idp/module/IdPModuleTest.java
+++ b/idp-admin-api/src/test/java/net/shibboleth/idp/module/IdPModuleTest.java
@@ -182,17 +182,9 @@ public class IdPModuleTest {
String vel = Files.readString(testHome.resolve("views/test.vm"));
Assert.assertEquals(vel, VEL_DATA);
- testModule.disable(context, true);
+ testModule.disable(context, false);
Assert.assertEquals(testHome.resolve("conf").toFile().listFiles().length, 0);
Assert.assertEquals(testHome.resolve("views").toFile().listFiles().length, 0);
-
- testModule.enable(context);
- testModule.disable(context, false);
- xml = Files.readString(testHome.resolve("conf/test.xml.idpsave"));
- Assert.assertEquals(xml, XML_DATA);
-
- vel = Files.readString(testHome.resolve("views/test.vm.idpsave"));
- Assert.assertEquals(vel, VEL_DATA);
}
@Test
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list