Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(controller): fix dataset/model copy error #1014

Merged
merged 1 commit into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ public void uploadBody(String uploadId, MultipartFile file,String uri){
String filename = file.getOriginalFilename();
try (InputStream inputStream = file.getInputStream()){
if(INDEX_FILE_NAME.equals(filename)){
try(CloseShieldInputStream csis = CloseShieldInputStream.wrap(inputStream)){
indexWriter.writeToStore(swDatasetVersionWithMeta.getSwDatasetVersionEntity().getIndexTable(),csis);
try(InputStream anotherInputStream = file.getInputStream()){
indexWriter.writeToStore(swDatasetVersionWithMeta.getSwDatasetVersionEntity().getIndexTable(),anotherInputStream);
}
}
if(AUTH_FILE_NAME.equals(filename)){
try(CloseShieldInputStream csis = CloseShieldInputStream.wrap(inputStream)){
try(InputStream anotherInputStream = file.getInputStream()){
swdsVersionMapper.updateStorageAuths(swDatasetVersionWithMeta.getSwDatasetVersionEntity()
.getId(), new String(csis.readAllBytes()));
.getId(), new String(anotherInputStream.readAllBytes()));
}
}
InputStream is = inputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,19 +347,15 @@ public void upload(MultipartFile dsFile,
: storagePathCoordinator.generateSwmpPath(projectEntity.getProjectName(),uploadRequest.name(), uploadRequest.version());
String jobContent = "";
try(final InputStream inputStream = dsFile.getInputStream()){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
inputStream.transferTo(baos);
InputStream is = new ByteArrayInputStream(baos.toByteArray());
InputStream is= inputStream;
if(dsFile.getSize() >= Integer.MAX_VALUE){
// TODO can not use this large memory, TBD
is = new LargeFileInputStream(inputStream,dsFile.getSize());
}
// only extract the eval job file content
jobContent = new String(
Objects.requireNonNull(TarFileUtil.getContentFromTarFile(is, "src", "eval_jobs.yaml")));

InputStream save = new ByteArrayInputStream(baos.toByteArray());
storageAccessService.put(String.format(FORMATTER_STORAGE_PATH,swmpPath,dsFile.getOriginalFilename()),save);
Objects.requireNonNull(TarFileUtil.getContentFromTarFile(dsFile.getInputStream(), "src", "eval_jobs.yaml")));
storageAccessService.put(String.format(FORMATTER_STORAGE_PATH,swmpPath,dsFile.getOriginalFilename()),is);
} catch (IOException e) {
log.error("upload swmp failed {}",uploadRequest.getSwmp(),e);
throw new StarWhaleApiException(new SWProcessException(ErrorType.STORAGE),
Expand Down