fix: Handles games where a "|" is part of the name. Better error handling for corrupted screenshots
This commit is contained in:
parent
13cf66ed34
commit
d302384ccc
|
@ -551,23 +551,23 @@ public class ImportManager
|
|||
|
||||
String advanced = splittedForPaths[16];
|
||||
|
||||
Path coverPath = srcCoversFolder.resolve(oldCoverName);
|
||||
Path targetCoverPath = Paths.get("./covers/" + coverName);
|
||||
|
||||
Path screens1Path = srcScreensFolder.resolve(oldScreen1Name);
|
||||
Path targetScreen1Path = Paths.get("./screens/" + screen1Name);
|
||||
|
||||
Path screens2Path = srcScreensFolder.resolve(oldScreen2Name);
|
||||
Path targetScreen2Path = Paths.get("./screens/" + screen2Name);
|
||||
|
||||
Path gamePath = srcGamesFolder.resolve(oldGameName);
|
||||
|
||||
Path targetGamePath = Paths.get("./games/" + gameName);
|
||||
|
||||
try
|
||||
{
|
||||
{
|
||||
logger.debug("RowData = {}", dbRowData);
|
||||
|
||||
Path coverPath = srcCoversFolder.resolve(oldCoverName);
|
||||
Path targetCoverPath = Paths.get("./covers/" + coverName);
|
||||
|
||||
Path screens1Path = srcScreensFolder.resolve(oldScreen1Name);
|
||||
Path targetScreen1Path = Paths.get("./screens/" + screen1Name);
|
||||
|
||||
Path screens2Path = srcScreensFolder.resolve(oldScreen2Name);
|
||||
Path targetScreen2Path = Paths.get("./screens/" + screen2Name);
|
||||
|
||||
Path gamePath = srcGamesFolder.resolve(oldGameName);
|
||||
|
||||
Path targetGamePath = Paths.get("./games/" + gameName);
|
||||
|
||||
if (gamebaseImport)
|
||||
{
|
||||
if (!oldGameName.isEmpty())
|
||||
|
@ -589,7 +589,7 @@ public class ImportManager
|
|||
Files.copy(coverPath, targetCoverPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
if (gamebaseImport)
|
||||
{
|
||||
FileManager.scaleCoverImageAndSave(targetCoverPath);
|
||||
FileManager.scaleCoverImageAndSave(targetCoverPath, gameName);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -623,7 +623,7 @@ public class ImportManager
|
|||
Files.copy(screens1Path, targetScreen1Path, StandardCopyOption.REPLACE_EXISTING);
|
||||
if (gamebaseImport)
|
||||
{
|
||||
FileManager.scaleScreenshotImageAndSave(targetScreen1Path);
|
||||
FileManager.scaleScreenshotImageAndSave(targetScreen1Path, gameName);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -645,7 +645,7 @@ public class ImportManager
|
|||
Files.copy(screens2Path, targetScreen2Path, StandardCopyOption.REPLACE_EXISTING);
|
||||
if (gamebaseImport)
|
||||
{
|
||||
FileManager.scaleScreenshotImageAndSave(targetScreen2Path);
|
||||
FileManager.scaleScreenshotImageAndSave(targetScreen2Path, gameName);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
@ -339,7 +339,7 @@ public class FileManager
|
|||
}
|
||||
// Do the conversion
|
||||
List<Character> forbiddenCharsList =
|
||||
" ,:'’-.!+*<>()/[]?".chars().mapToObj(item -> (char) item).collect(Collectors.toList());
|
||||
" ,:'’-.!+*<>()/[]?|".chars().mapToObj(item -> (char) item).collect(Collectors.toList());
|
||||
|
||||
List<Character> newName =
|
||||
title.chars().mapToObj(item -> (char) item).filter(character -> !forbiddenCharsList.contains(character))
|
||||
|
@ -948,7 +948,7 @@ public class FileManager
|
|||
});
|
||||
}
|
||||
|
||||
public static void scaleCoverImageAndSave(Path coverImagePath)
|
||||
public static void scaleCoverImageAndSave(Path coverImagePath, String gameName)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -963,11 +963,20 @@ public class FileManager
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
ExceptionHandler.handleException(e, "Could not scale and cover");
|
||||
ExceptionHandler.logException(e, "Could not scale and store cover for " + gameName + ", using missing cover instead");
|
||||
//Use missing file
|
||||
try
|
||||
{
|
||||
ImageIO.write(emptyC64Cover, "png", coverImagePath.toFile());
|
||||
}
|
||||
catch (IOException e1)
|
||||
{
|
||||
ExceptionHandler.logException(e1, "Could not store empty cover for " + gameName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void scaleScreenshotImageAndSave(Path screenshotImagePath)
|
||||
public static void scaleScreenshotImageAndSave(Path screenshotImagePath, String gameName)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -976,7 +985,16 @@ public class FileManager
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
ExceptionHandler.handleException(e, "Could not scale and store screenshot");
|
||||
ExceptionHandler.logException(e, "Could not scale and store screenshot for " + gameName + ", using empty screenshot instead");
|
||||
//Use missing file
|
||||
try
|
||||
{
|
||||
ImageIO.write(emptyC64Screenshot, "png", screenshotImagePath.toFile());
|
||||
}
|
||||
catch (IOException e1)
|
||||
{
|
||||
ExceptionHandler.logException(e1, "Could not store empty screenshot for " + gameName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue