Skip to content

Commit

Permalink
avoid overwriting of ots file in stamp
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Mar 14, 2017
1 parent 46887fd commit 975b636
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main/java/com/eternitywall/OtsCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,24 @@ public static void info (String argsOts) {
private static void stamp(String argsFile, List<String> calendarsUrl, Integer m) {
FileInputStream fis = null;
try {

String argsOts = argsFile + ".ots";
Path path = Paths.get(argsOts);
if(Files.exists(path)) {
System.out.println("File '" + argsOts + "' already exist");
return;
}
File file = new File(argsFile);
fis = new FileInputStream(file);
byte[] stampResult = OpenTimestamps.stamp(fis,calendarsUrl,m);
//System.out.println(Utils.bytesToHex(stampResult));

String argsOts = argsFile + ".ots";
Files.write(Paths.get(argsOts), stampResult);
Files.write(path, stampResult);
System.out.println("The timestamp proof '" + argsOts + "' has been created!");

} catch (IOException e) {
e.printStackTrace();
log.severe("No valid file");
} finally {
try {
fis.close();
if(fis!=null)
fis.close();
}catch (IOException e) {
log.severe("No valid file");
}
Expand Down

0 comments on commit 975b636

Please sign in to comment.