Skip to content

Commit

Permalink
[MRESOLVER-331] Make DefaultTrackingFileManager write directly to tra…
Browse files Browse the repository at this point in the history
…cking files

This closes #259
  • Loading branch information
michael-o committed Feb 26, 2023
1 parent 8df4ebc commit 23cd526
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.Map;
import java.util.Properties;

import org.eclipse.aether.util.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -46,7 +45,7 @@ public final class DefaultTrackingFileManager implements TrackingFileManager {
@Override
public Properties read(File file) {
Path filePath = file.toPath();
if (Files.isRegularFile(filePath)) {
if (Files.isReadable(filePath)) {
try (InputStream stream = Files.newInputStream(filePath)) {
Properties props = new Properties();
props.load(stream);
Expand Down Expand Up @@ -86,15 +85,13 @@ public Properties update(File file, Map<String, String> updates) {
}
}

FileUtils.writeFile(filePath, p -> {
try (OutputStream stream = Files.newOutputStream(p)) {
LOGGER.debug("Writing tracking file '{}'", file);
props.store(
stream,
"NOTE: This is a Maven Resolver internal implementation file"
+ ", its format can be changed without prior notice.");
}
});
try (OutputStream stream = Files.newOutputStream(filePath)) {
LOGGER.debug("Writing tracking file '{}'", file);
props.store(
stream,
"NOTE: This is a Maven Resolver internal implementation file"
+ ", its format can be changed without prior notice.");
}
} catch (IOException e) {
LOGGER.warn("Failed to write tracking file '{}'", file, e);
throw new UncheckedIOException(e);
Expand Down

0 comments on commit 23cd526

Please sign in to comment.