Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne Homer <[email protected]>
  • Loading branch information
etiennehomer committed Sep 27, 2024
1 parent 2aba9eb commit 59cdeed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.stereotype.Service;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Set;
import java.util.UUID;

Expand Down Expand Up @@ -51,17 +52,9 @@ public Boolean datasourceExists(UUID caseUuid, String fileName) {
public byte[] getInputStream(UUID caseUuid, String fileName) {
final var caseFileKey = uuidToPrefixKey(caseUuid) + fileName;
return withS3DownloadedDataSource(caseUuid, caseFileKey,
datasource -> IOUtils.toByteArray(datasource.newInputStream(fileName)));
datasource -> IOUtils.toByteArray(datasource.newInputStream(Paths.get(fileName).getFileName().toString())));
}

// @Override
// public byte[] getInputStream(UUID caseUuid, String fileName) {
// final String parsedFileName = fileName.substring(fileName.indexOf('/') + 1);
// final var caseFileKey = uuidToPrefixKey(caseUuid) + parsedFileName;
// return withS3DownloadedDataSource(caseUuid, caseFileKey,
// datasource -> IOUtils.toByteArray(datasource.newInputStream(parsedFileName)));
// }

private String uuidToPrefixKey(UUID uuid) {
return CASES_PREFIX + uuid.toString() + "/";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.powsybl.computation.local.LocalComputationManager;
import com.powsybl.iidm.network.Importer;
import com.powsybl.iidm.network.Network;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.function.FailableConsumer;
import org.apache.commons.lang3.function.FailableFunction;
import org.slf4j.Logger;
Expand Down Expand Up @@ -98,7 +99,7 @@ private <R, T1 extends Throwable, T2 extends Throwable> R withTempCopy(UUID case
FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwx------"));
tempdirPath = Files.createTempDirectory(caseUuid.toString(), attr);
if (Paths.get(filename).getParent() != null) {
Files.createDirectory(Paths.get(tempdirPath.toString(), (Paths.get(filename).getParent().toString())), attr);
Files.createDirectory(Paths.get(tempdirPath.toString(), Paths.get(filename).getParent().toString()), attr);
}
// after this line, need to cleanup the dir
} catch (IOException e) {
Expand Down Expand Up @@ -131,7 +132,7 @@ private <R, T1 extends Throwable, T2 extends Throwable> R withTempCopy(UUID case
}
} finally {
try {
Files.delete(tempdirPath);
FileUtils.deleteDirectory(tempdirPath.toFile());
} catch (IOException e) {
LOGGER.error("Error cleaning up temporary case dir", e);
}
Expand Down

0 comments on commit 59cdeed

Please sign in to comment.