Fix Render data attempting to recreate files on setting change

This commit is contained in:
James Seibel
2023-08-18 07:47:18 -05:00
parent c80136719d
commit 11ec8b1eaa
2 changed files with 21 additions and 4 deletions
@@ -80,6 +80,24 @@ public class RenderMetaDataFile extends AbstractMetaDataContainerFile implements
// constructor //
//=============//
/**
* Can be used instead of {@link RenderMetaDataFile#createFromExistingFile} or {@link RenderMetaDataFile#createNewFileForPos},
* if we are uncertain whether a file exists or not.
*/
public static RenderMetaDataFile createFromExistingOrNewFile(RenderSourceFileHandler fileHandler, DhSectionPos pos) throws IOException
{
File file = fileHandler.computeRenderFilePath(pos);
if (file.exists())
{
return createFromExistingFile(fileHandler, file);
}
else
{
return createNewFileForPos(fileHandler, pos);
}
}
/**
* NOTE: should only be used if there is NOT an existing file.
*
@@ -310,12 +310,11 @@ public class RenderSourceFileHandler implements ILodRenderSourceProvider
return null;
}
// File does not exist, create it.
// In this case, since 'creating' a file object doesn't actually do anything heavy on IO yet, we use CAS
// to avoid overhead of 'synchronized', and eat the mini-overhead of possibly creating duplicate objects.
// File probably doesn't exist, try creating it.
try
{
metaFile = RenderMetaDataFile.createNewFileForPos(this, pos);
// createFromExistingOrNewFile is due to a rare issue where the file may already exist but isn't in the file list
metaFile = RenderMetaDataFile.createFromExistingOrNewFile(this, pos);
}
catch (IOException e)
{