Skip to content

Commit

Permalink
Update CsvReporterConfig.java
Browse files Browse the repository at this point in the history
This should address issue addthis#24 - addthis#24 .
  • Loading branch information
ianilsley authored Jun 22, 2016
1 parent cea50b4 commit d880583
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,22 @@ public boolean enable()
boolean success = foutDir.mkdirs();
if (!success)
{
log.error("Failed to create directory {} for CsvReporter", outdir);
//Did we fail because the file already existed ?
//Ok , lets rename the existing file so we dont loose it
//and then re-create it.
if ( foutDir.exists() )
{
String newName = foutDir.getAbsolutePath()+System.currentTimeMillis();
log.error("metics: Failed to create directory {} for CsvReporter. It already exists. Renaming to {} ", outdir , newName );
foutDir.renameTo( new File(newName));
success = foutDir.mkdirs();
}
}

// checking for success again as it may have initially failed and the rename worked but we still failed to mkdir.
if (!success)
{
log.error("metrics: Failed to create or rename directory {} for CsvReporter. ", outdir );
return false;
}
// static enable() methods omit the option of specifying a
Expand Down

0 comments on commit d880583

Please sign in to comment.