Browse Source

Improved logging

qdn
CalDescent 3 years ago
parent
commit
be0426d9a2
  1. 1
      src/main/java/org/qortal/arbitrary/ArbitraryDataBuilder.java
  2. 3
      src/main/java/org/qortal/arbitrary/ArbitraryDataCombiner.java
  3. 5
      src/main/java/org/qortal/arbitrary/ArbitraryDataReader.java

1
src/main/java/org/qortal/arbitrary/ArbitraryDataBuilder.java

@ -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();

3
src/main/java/org/qortal/arbitrary/ArbitraryDataCombiner.java

@ -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());

5
src/main/java/org/qortal/arbitrary/ArbitraryDataReader.java

@ -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());

Loading…
Cancel
Save