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

MicronautHttpData cannot delete temporary files on Windows #10678

Open
loicmathieu opened this issue Apr 3, 2024 · 1 comment
Open

MicronautHttpData cannot delete temporary files on Windows #10678

loicmathieu opened this issue Apr 3, 2024 · 1 comment

Comments

@loicmathieu
Copy link

Expected Behavior

Temporary files created by file upload should be deleted on Windows

Actual Behaviour

On Windows 10 (it works fine on Linux), the temporary file created by a file upload is not deleted, increasing the disk size.
Moreover, a warning is issued:

grafik

Steps To Reproduce

The endpoint where we upload the file is the following:

@ExecuteOn(TaskExecutors.IO)
    @Post(uri = "/{namespace}/{id}", consumes = MediaType.MULTIPART_FORM_DATA)
    public Execution create(
        @Parameter(description = "The inputs") HttpRequest<?> inputs, 
        @Parameter(description = "The inputs of type file") @Nullable @Part Publisher<StreamingFileUpload> files
    ) throws IOException {
    }

The files are process like that:

 Map<String, String> uploads = Flux.from(files)
            .subscribeOn(Schedulers.boundedElastic())
            .map(throwFunction(file -> {
                File tempFile = File.createTempFile(file.getFilename() + "_", ".upl");
                Publisher<Boolean> uploadPublisher = file.transferTo(tempFile);
                Boolean bool = Mono.from(uploadPublisher).block();

                if (Boolean.FALSE.equals(bool)) {
                    throw new RuntimeException("Can't upload");
                }

                URI from = storageInterface.from(execution, file.getFilename(), tempFile);
                //noinspection ResultOfMethodCallIgnored
                tempFile.delete();

                return new AbstractMap.SimpleEntry<>(
                    file.getFilename(),
                    from.toString()
                );
            }))
            .collectMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)
            .block();

Environment Information

  • OS: Windows 10
  • Java 17

Example Application

No response

Version

4.3.4

@yawkat
Copy link
Member

yawkat commented Apr 23, 2024

I don't think we can do much about this if we can't delete files we created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants