Skip to content
Snippets Groups Projects
Commit df27010b authored by kaloyane's avatar kaloyane
Browse files

[LMS-2264] do not leave invalid data set folders in the data store if a...

[LMS-2264] do not leave invalid data set folders in the data store if a storage processor transaction fails

SVN: 21641
parent eae627ac
No related branches found
No related tags found
No related merge requests found
...@@ -17,12 +17,18 @@ ...@@ -17,12 +17,18 @@
package ch.systemsx.cisd.etlserver; package ch.systemsx.cisd.etlserver;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.exceptions.Status;
import ch.systemsx.cisd.common.filesystem.FileUtilities; import ch.systemsx.cisd.common.filesystem.FileUtilities;
import ch.systemsx.cisd.common.logging.LogCategory;
import ch.systemsx.cisd.common.logging.LogFactory;
import ch.systemsx.cisd.common.mail.IMailClient; import ch.systemsx.cisd.common.mail.IMailClient;
import ch.systemsx.cisd.common.utilities.PropertyUtils; import ch.systemsx.cisd.common.utilities.PropertyUtils;
import ch.systemsx.cisd.etlserver.utils.Unzipper; import ch.systemsx.cisd.etlserver.utils.Unzipper;
...@@ -44,6 +50,9 @@ public class DefaultStorageProcessor extends AbstractStorageProcessor ...@@ -44,6 +50,9 @@ public class DefaultStorageProcessor extends AbstractStorageProcessor
static final String DELETE_UNZIPPED_KEY = "delete_unzipped"; static final String DELETE_UNZIPPED_KEY = "delete_unzipped";
private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION,
DefaultStorageProcessor.class);
private final boolean unzip; private final boolean unzip;
private final boolean deleteUnzipped; private final boolean deleteUnzipped;
...@@ -105,11 +114,19 @@ public class DefaultStorageProcessor extends AbstractStorageProcessor ...@@ -105,11 +114,19 @@ public class DefaultStorageProcessor extends AbstractStorageProcessor
File targetFile = File targetFile =
new File(getOriginalDirectory(storedDataDirectory), new File(getOriginalDirectory(storedDataDirectory),
incomingDataSetDirectory.getName()); incomingDataSetDirectory.getName());
// Note that this will move back <code>targetFilePath</code> to its original place but
// the
// directory structure will persist. Right now, we consider this is fine as these empty
// directories will not disturb the running application.
FileRenamer.renameAndLog(targetFile, incomingDataSetDirectory); FileRenamer.renameAndLog(targetFile, incomingDataSetDirectory);
try
{
FileUtils.deleteDirectory(storedDataDirectory);
} catch (IOException ex1)
{
String message = String.format("Failed to remove stored directory '%s'. " +
"In the future the creation of a data set with the same code will fail. " +
"To fix the problem remove the directory manually.");
operationLog.warn(message);
}
return getDefaultUnstoreDataAction(ex); return getDefaultUnstoreDataAction(ex);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment