Removed use of Files.isRegularFile from UI module, references #592

This commit is contained in:
Sebastian Stenzel
2017-11-14 18:12:22 +01:00
parent 46cab2ef9a
commit a7c42c3d59
3 changed files with 5 additions and 10 deletions

View File

@@ -112,13 +112,8 @@ public abstract class UpgradeStrategy {
public boolean isApplicable(Vault vault) {
final Path masterkeyFile = vault.getPath().resolve(MASTERKEY_FILENAME);
try {
if (Files.isRegularFile(masterkeyFile)) {
byte[] masterkeyFileContents = Files.readAllBytes(masterkeyFile);
return KeyFile.parse(masterkeyFileContents).getVersion() == vaultVersionBeforeUpgrade;
} else {
LOG.warn("Not a file: {}", masterkeyFile);
return false;
}
byte[] masterkeyFileContents = Files.readAllBytes(masterkeyFile);
return KeyFile.parse(masterkeyFileContents).getVersion() == vaultVersionBeforeUpgrade;
} catch (IOException e) {
LOG.warn("Could not determine, whether upgrade is applicable.", e);
return false;

View File

@@ -97,7 +97,7 @@ class UpgradeVersion3to4 extends UpgradeStrategy {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
String name = file.getFileName().toString();
if (!attrs.isRegularFile() || attrs.size() > FILE_MIN_SIZE) {
if (attrs.size() > FILE_MIN_SIZE) {
LOG.trace("Skipping non-directory file {}.", file);
} else if (name.endsWith(LONG_FILENAME_EXT)) {
migrateLong(metadataDir, file);
@@ -147,7 +147,7 @@ class UpgradeVersion3to4 extends UpgradeStrategy {
String oldCanonicalName = oldNameBase32 + LONG_FILENAME_EXT;
Path oldMetadataFile = metadataDir.resolve(oldCanonicalName.substring(0, 2)).resolve(oldCanonicalName.substring(2, 4)).resolve(oldCanonicalName);
if (!Files.isRegularFile(oldMetadataFile)) {
if (!Files.isReadable(oldMetadataFile)) {
LOG.warn("Found uninflatable long file name. Expected: {}", oldMetadataFile);
return;
}

View File

@@ -83,7 +83,7 @@ class UpgradeVersion4to5 extends UpgradeStrategy {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (attrs.isRegularFile() && BASE32_PATTERN.matcher(file.getFileName().toString()).find() && attrs.size() > cryptor.fileHeaderCryptor().headerSize()) {
if (BASE32_PATTERN.matcher(file.getFileName().toString()).find() && attrs.size() > cryptor.fileHeaderCryptor().headerSize()) {
migrate(file, attrs, cryptor);
} else {
LOG.info("Skipping irrelevant file {}.", file);