Skip to content

Commit

Permalink
feat: better loggers for directory management
Browse files Browse the repository at this point in the history
  • Loading branch information
FY2QEQ authored and FY2QEQ committed Jul 18, 2024
1 parent 30c71ee commit 28fb554
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ public static boolean isCompletelyWritten(File file) {
*/
public static void createDirIfNotexist(File directoryToCreate) {
if (!directoryToCreate.exists()) {
directoryToCreate.mkdirs();
if (!directoryToCreate.mkdirs())
{
LoggerHelper.error(LOGGER, "Le répertoire ", directoryToCreate.getAbsolutePath(), " n'a pas pu être créé");
}
}
}

Expand All @@ -46,6 +49,18 @@ public static void createDirIfNotexist(File directoryToCreate) {
* @param f
*/
public static void createDirIfNotexist(String fPath) {

File fileToProceed = new File(fPath);

if (fileToProceed.exists() && !fileToProceed.isDirectory())
{
try {
delete(fileToProceed);
} catch (ArcException e) {
LoggerHelper.error(LOGGER, "Le fichier ", fileToProceed.getAbsolutePath(), " n'a pas pu être effacé");
}
}

createDirIfNotexist(new File(fPath));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void download(String sourceS3Path, String targetFilePath) throws ArcExcep
| InvalidResponseException | NoSuchAlgorithmException | ServerException | XmlParserException
| IllegalArgumentException | IOException e) {

throw new ArcException(ArcExceptionMessage.FILE_COPY_FAILED, sourceS3Path, targetFile.getName());
throw new ArcException(ArcExceptionMessage.FILE_COPY_FAILED, sourceS3Path, targetFile.getAbsolutePath());
}
}

Expand Down Expand Up @@ -234,7 +234,7 @@ public void upload(File fileFrom, String pathTo) throws ArcException {
| InvalidResponseException | NoSuchAlgorithmException | ServerException | XmlParserException
| IllegalArgumentException | IOException e) {

throw new ArcException(ArcExceptionMessage.FILE_COPY_FAILED, fileFrom.getName(), pathTo);
throw new ArcException(ArcExceptionMessage.FILE_COPY_FAILED, fileFrom.getAbsolutePath(), pathTo);
}
}

Expand Down

0 comments on commit 28fb554

Please sign in to comment.