remove duplicate renameCorruptedFile() code
This commit is contained in:
@@ -64,29 +64,8 @@ public class FullDataFileHandler implements IFullDataSourceProvider
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.error("Failed to read data meta file at {}: ", file, e);
|
||||
File corruptedFile = new File(file.getParentFile(), file.getName() + ".corrupted");
|
||||
|
||||
if (corruptedFile.exists())
|
||||
{
|
||||
if (!corruptedFile.delete())
|
||||
{
|
||||
LOGGER.error("Failed to delete corrupted meta data file at {}: ", corruptedFile, e);
|
||||
}
|
||||
}
|
||||
|
||||
if (file.renameTo(corruptedFile))
|
||||
{
|
||||
LOGGER.error("Renamed corrupted file to {}", file.getName() + ".corrupted");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.error("Failed to rename corrupted file to {}. Will try and delete file", file.getName() + ".corrupted");
|
||||
if (file.delete())
|
||||
{
|
||||
LOGGER.error("Failed to delete corrupted meta data file at {}: ", file, e);
|
||||
}
|
||||
}
|
||||
LOGGER.error("Failed to read data meta file at "+file+": ", e);
|
||||
FileUtil.renameCorruptedFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-22
@@ -9,6 +9,7 @@ import com.seibel.lod.core.file.fullDatafile.IFullDataSourceProvider;
|
||||
import com.seibel.lod.core.level.IDhClientLevel;
|
||||
import com.seibel.lod.core.pos.DhLodPos;
|
||||
import com.seibel.lod.core.pos.DhSectionPos;
|
||||
import com.seibel.lod.core.util.FileUtil;
|
||||
import com.seibel.lod.core.util.objects.UncheckedInterruptedException;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
@@ -71,28 +72,7 @@ public class RenderSourceFileHandler implements ILodRenderSourceProvider
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.error("Failed to read render meta file at ["+file+"]. Error: ", e);
|
||||
String corruptedFileName = file.getName() + ".corrupted";
|
||||
|
||||
File corruptedFile = new File(file.getParentFile(), corruptedFileName);
|
||||
if (corruptedFile.exists())
|
||||
{
|
||||
// could happen if there was a corrupted file before that was removed
|
||||
corruptedFile.delete();
|
||||
}
|
||||
|
||||
|
||||
if (file.renameTo(corruptedFile))
|
||||
{
|
||||
LOGGER.error("Renamed corrupted file to ["+corruptedFileName+"].");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.error("Failed to rename corrupted file to ["+corruptedFileName+"]. Attempting to delete file...");
|
||||
if (!file.delete())
|
||||
{
|
||||
LOGGER.error("Unable to delete corrupted file ["+corruptedFileName+"].");
|
||||
}
|
||||
}
|
||||
FileUtil.renameCorruptedFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user