git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/data-transfer/data-transfer-service/2.0@158413 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8fccae4fe6
commit
a4a6b11872
|
@ -3,7 +3,6 @@ package org.gcube.data.transfer.service.transfers.engine.impl;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -126,8 +125,8 @@ public class PersistenceProviderImpl implements PersistenceProvider {
|
|||
break;
|
||||
}
|
||||
case FAIL: throw new DestinationAccessException("Found existing "+clashing.getAbsolutePath()+"policy is "+policy);
|
||||
case REWRITE : {
|
||||
Files.deleteIfExists(Paths.get(clashing.getAbsolutePath()));
|
||||
case REWRITE : {
|
||||
deleteRecursively(clashing);
|
||||
if(dir)clashing.mkdirs();
|
||||
else clashing.createNewFile();
|
||||
break;
|
||||
|
@ -138,4 +137,13 @@ public class PersistenceProviderImpl implements PersistenceProvider {
|
|||
}
|
||||
return clashing;
|
||||
}
|
||||
|
||||
|
||||
private static final void deleteRecursively(File toDelete) throws IOException {
|
||||
log.warn("Recursively deleting {} ",toDelete.getAbsolutePath());
|
||||
if(toDelete.isDirectory()) {
|
||||
for(File child:toDelete.listFiles())
|
||||
deleteRecursively(child);
|
||||
}else Files.deleteIfExists(toDelete.toPath());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue