Skip to content

Commit 62ed696

Browse files
committed
make code better
1 parent aa79280 commit 62ed696

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/main/java/life/qbic/registration/openbis/OpenBisDropboxETL.java

+4-14
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,16 @@ public void process(IDataSetRegistrationTransactionV2 transaction) {
7777

7878
private void moveFiles(IDataSetRegistrationTransactionV2 transactionV2, IDataSet dataSet, File provenanceFile) {
7979

80-
byte[] buffer = null;
8180
try {
82-
buffer = Files.readAllBytes(provenanceFile.toPath().toAbsolutePath());
81+
var buffer = Files.readAllBytes(provenanceFile.toPath().toAbsolutePath());
8382
Files.delete(provenanceFile.toPath());
84-
transactionV2.moveFile(transactionV2.getIncoming().getAbsolutePath(), dataSet);
85-
} catch (RuntimeException e) {
86-
//recover provenance file
8783
try {
84+
transactionV2.moveFile(transactionV2.getIncoming().getAbsolutePath(), dataSet);
85+
} catch (Exception e) {
8886
Files.write(provenanceFile.toPath().toAbsolutePath(), buffer);
89-
} catch (IOException ex) {
90-
throw new RuntimeException(ex);
87+
throw new RuntimeException(e);
9188
}
92-
throw e;
9389
} catch (IOException e) {
94-
//recover provenance file
95-
try {
96-
Files.write(provenanceFile.toPath().toAbsolutePath(), buffer);
97-
} catch (IOException ex) {
98-
throw new RuntimeException(ex);
99-
}
10090
throw new RuntimeException(e);
10191
}
10292
}

0 commit comments

Comments
 (0)