|
14 | 14 | import javax.inject.Named; |
15 | 15 | import java.io.IOException; |
16 | 16 | import java.nio.charset.StandardCharsets; |
17 | | -import java.nio.file.FileAlreadyExistsException; |
18 | 17 | import java.nio.file.Files; |
19 | 18 | import java.nio.file.NoSuchFileException; |
20 | 19 | import java.nio.file.Path; |
@@ -123,18 +122,17 @@ private Stream<Node> renameConflictingFile(Path canonicalPath, Node conflicting) |
123 | 122 | } |
124 | 123 |
|
125 | 124 | assert alternativeCiphertextName.length() <= maxC9rFileNameLength; |
126 | | - try { |
127 | | - Files.move(conflicting.ciphertextPath, alternativePath, StandardCopyOption.ATOMIC_MOVE); |
128 | | - LOG.info("Renamed conflicting file {} to {}...", conflicting.ciphertextPath, alternativePath); |
129 | | - Node node = new Node(alternativePath); |
130 | | - node.cleartextName = alternativeCleartext; |
131 | | - node.extractedCiphertext = alternativeCiphertext; |
132 | | - return Stream.of(node); |
133 | | - } catch (FileAlreadyExistsException e) { |
134 | | - // TODO notify user about unresolved conflict: `canonicalPath` |
135 | | - LOG.warn("Failed to rename conflicting file {} to {}. Keeping original name.", conflicting.ciphertextPath, alternativePath); |
| 125 | + if (Files.exists(alternativePath)) { |
| 126 | + LOG.warn("Failed finding alternative name for {}. Keeping original name.", conflicting.ciphertextPath); |
136 | 127 | return Stream.empty(); |
137 | 128 | } |
| 129 | + |
| 130 | + Files.move(conflicting.ciphertextPath, alternativePath, StandardCopyOption.ATOMIC_MOVE); |
| 131 | + LOG.info("Renamed conflicting file {} to {}...", conflicting.ciphertextPath, alternativePath); |
| 132 | + Node node = new Node(alternativePath); |
| 133 | + node.cleartextName = alternativeCleartext; |
| 134 | + node.extractedCiphertext = alternativeCiphertext; |
| 135 | + return Stream.of(node); |
138 | 136 | } |
139 | 137 |
|
140 | 138 |
|
|
0 commit comments