Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MODE-1483 - Fixed erroneous deletion of the parent file when cleaning…

… up content
  • Loading branch information...
commit 421e578862c011c9aaba2a402cadd2811afcf9d1 1 parent c11bc70
@hchiorean authored
View
7 ...modeshape-connector-filesystem/src/main/java/org/modeshape/connector/filesystem/FileSystemWorkspace.java
@@ -417,7 +417,6 @@ public PathNode removeNode( Path nodePath ) {
getName(),
source.getName()));
} finally {
- FileUtil.delete(nodeFile);
if (fos != null) try {
fos.close();
} catch (IOException ioe) {
@@ -446,7 +445,7 @@ public PathNode removeNode( Path nodePath ) {
nodeFile,
NO_PROPERTIES);
File propertiesFile = customPropertiesFactory.propertiesFileForFile(nodeFile);
- if (propertiesFile != null) {
+ if (propertiesFile != null && propertiesFile.exists()) {
FileUtil.delete(propertiesFile);
}
} else if (JcrNtLexicon.FOLDER.equals(primaryType)) {
@@ -457,7 +456,7 @@ public PathNode removeNode( Path nodePath ) {
nodeFile,
NO_PROPERTIES);
File propertiesFile = customPropertiesFactory.propertiesFileForFolder(nodeFile);
- if (propertiesFile != null) {
+ if (propertiesFile != null && propertiesFile.exists()) {
FileUtil.delete(propertiesFile);
}
} else {
@@ -467,7 +466,7 @@ public PathNode removeNode( Path nodePath ) {
nodeFile,
NO_PROPERTIES);
File propertiesFile = customPropertiesFactory.propertiesFileForResource(nodeFile);
- if (propertiesFile != null) {
+ if (propertiesFile != null && propertiesFile.exists()) {
FileUtil.delete(propertiesFile);
}
}
View
12 ...n-tests/src/test/java/org/modeshape/test/integration/filesystem/FileSystemRepositoryIntegrationTest.java
@@ -23,6 +23,7 @@
*/
package org.modeshape.test.integration.filesystem;
+import javax.jcr.PropertyIterator;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import java.io.File;
@@ -338,7 +339,7 @@ public void shouldAllowReindexingSubgraphAsynchronously() throws Exception {
@FixFor("MODE-1483")
@Test
- public void shouldRemoveFileCreatedByFilesystemConnector() throws Exception {
+ public void shouldRemoveExtraFilesCreatedWhenStoringAdditionalProperties() throws Exception {
File repositoryRoot = new File("./target/fileSystemSource");
try {
if (!repositoryRoot.exists() || !repositoryRoot.isDirectory()) {
@@ -358,7 +359,16 @@ public void shouldRemoveFileCreatedByFilesystemConnector() throws Exception {
jcrTools.uploadFile(session, "/folder/file2", getClass().getClassLoader().getResource(resourcePath));
session.save();
+ //remove everything for the file which is under root
+ fileUnderRoot = session.getNode("/test.file");
+ jcrTools.removeAllChildren(fileUnderRoot);
+ PropertyIterator pIt = fileUnderRoot.getProperties();
+ while (pIt.hasNext()) {
+ javax.jcr.Property property = pIt.nextProperty();
+ property.remove();
+ }
fileUnderRoot.remove();
+
folder.remove();
session.save();
Please sign in to comment.
Something went wrong with that request. Please try again.