Improved logging

This commit is contained in:
CalDescent 2021-08-15 19:19:55 +01:00
parent 8fac0a02e5
commit be0426d9a2
3 changed files with 8 additions and 1 deletions

View File

@ -152,6 +152,7 @@ public class ArbitraryDataBuilder {
// Loop from the second path onwards
for (int i=1; i<paths.size(); i++) {
LOGGER.info(String.format("[%s][%s] Applying layer %d...", this.service, this.name, i));
Path pathAfter = this.paths.get(i);
ArbitraryDataCombiner combiner = new ArbitraryDataCombiner(pathBefore, pathAfter);
combiner.combine();

View File

@ -7,6 +7,7 @@ import org.qortal.utils.FilesystemUtils;
import java.io.File;
import java.io.IOException;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.Files;
import java.nio.file.Path;
@ -55,6 +56,8 @@ public class ArbitraryDataCombiner {
if (FilesystemUtils.pathInsideDataOrTempPath(parentDirectory)) {
try {
Files.deleteIfExists(parentDirectory);
} catch (DirectoryNotEmptyException e) {
// No need to log anything
} catch (IOException e) {
// This will eventually be cleaned up by a maintenance process, so log the error and continue
LOGGER.info("Unable to cleanup parent directory {}", parentDirectory.toString());

View File

@ -219,7 +219,8 @@ public class ArbitraryDataReader {
if (!arbitraryDataFile.exists()) {
if (!arbitraryDataFile.allChunksExist(chunkHashes)) {
// TODO: fetch them?
throw new IllegalStateException(String.format("Missing chunks for file {}", arbitraryDataFile));
LOGGER.info(String.format("Missing chunks for file {}", arbitraryDataFile));
throw new IllegalStateException(String.format("Missing chunks for file %s", arbitraryDataFile));
}
// We have all the chunks but not the complete file, so join them
arbitraryDataFile.addChunkHashes(chunkHashes);
@ -317,6 +318,8 @@ public class ArbitraryDataReader {
Files.deleteIfExists(parentDirectory);
}
} catch (DirectoryNotEmptyException e) {
// No need to log anything
} catch (IOException e) {
// This will eventually be cleaned up by a maintenance process, so log the error and continue
LOGGER.info("Unable to cleanup directories: {}", e.getMessage());