Browse Source

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

Sebastian Stenzel 7 years ago
parent
commit
a7c42c3d59

+ 2 - 7
main/ui/src/main/java/org/cryptomator/ui/model/UpgradeStrategy.java

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

+ 2 - 2
main/ui/src/main/java/org/cryptomator/ui/model/UpgradeVersion3to4.java

@@ -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;
 			}

+ 1 - 1
main/ui/src/main/java/org/cryptomator/ui/model/UpgradeVersion4to5.java

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