remove duplicate renameCorruptedFile() code

This commit is contained in:
James Seibel
2023-02-19 12:30:14 -06:00
parent 0615a2917c
commit cf34457d20
2 changed files with 4 additions and 45 deletions
@@ -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);
}
}
}
@@ -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);
}
}