fix: uploading books on Windows (dev env) doesn't work #138
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While trying to setup a dev environment on my main PC (Windows), I met with an error.
The error comes from Tomcat or even JDK implementation, because they handle
transferTo(File)
andtransferTo(Path)
differently. In the project, you use the Path more often and resolve its child (e.g. inPathService
). But here inFileUploadService
,transferTo(File)
was used.Some examples:
storagePath
is equal to: \forks\BookLore\local\booktitle.epubstorageFile
is equal to the same, but ontransferTo(storageFile)
, I receivedWhere we can see the path of the file was resolved to
C:\Users\astappiev\AppData\Local\Temp\tomcat.8080.6568768355172360310\work\Tomcat\localhost\ROOT\forks\BookLore\local\booktitle.epub
.Replacing it with
transferTo(storagePath)
fixes the error, and my files upload without any errors.I'm not sure if there are any performance with difference between these two methods, it seems like
transferTo(Path)
reads the file into buffer and writes into another OutputFileStream, whiletransferTo(File)
is doing something else, the implementation is hidden in the JDK, so probably it was more performant as implemented low level. However, I consider this difference such that it can be neglected.Also in this PR:
pathBook
, as it's not used and probably obsolete because now it's per library.FileProcessingUtils
to usefileService.getThumbnailPath
to make it consistent and more error resistant