Avoid empty file creation via WebDAV when using Finder
When uploading files via WebDAV using Finder, it sends an empty file at first and then send the file with the actual expected size. The goal here is to avoid empty file generation.
Expected Behavior
Finder not uploading empty files.
Current Behavior
Finder uploads empty versions of the file even if the file to be uploaded is not empty.
Possible Solution
Write a "~DOTEMPTY" to the file when empty.
Steps to Reproduce (for bugs)
- Set up WebDAV with Finder. See here for detailed instructions.
- Upload a File
- Go to the Content edit screen and see the history. First version of the file will be zero bytes
Context
Avoid the creation of empty files in the system.
PR https://github.com/dotCMS/core/pull/10052
Moving files and folders does not work. This is because we call DavHelper.stripMappings all over the place in methods and in methods called by those methods and so stripMappings thows an unnecessary io error.
Example here in the move():
https://github.com/dotCMS/core/blob/dd68246d3d56a2faba68b569ee8b1670e5deab8f/dotCMS/src/main/java/com/dotmarketing/webdav/DotWebdavHelper.java#L1122:L1123
Then lower down we call isResource https://github.com/dotCMS/core/blob/dd68246d3d56a2faba68b569ee8b1670e5deab8f/dotCMS/src/main/java/com/dotmarketing/webdav/DotWebdavHelper.java#L1141
Which "stripsMappings" again https://github.com/dotCMS/core/blob/dd68246d3d56a2faba68b569ee8b1670e5deab8f/dotCMS/src/main/java/com/dotmarketing/webdav/DotWebdavHelper.java#L262
Eric I just pushed a possible fix - can you test this?
sure Will going to test it in a few minutes
The move is working now, but when I upload a new File using Finder it throws me an error: "This file already exists" (I guess this is because on how Finder works, first uploads the file empty and the uploads the metadata). Tomorrow gonna take a deeper look at this.
Passed QA. Tested issue in latest master-3.7, MySQL 5.6.23, Postgres 9.3, Firefox -Uploaded empty files and non-empty files and verify that there's no empty file generation -Added folder/files in root and inside folders -Was able to move folder/files from root to another folders and viceversa -Followed tests above with multilingual files and verify that there's no empty file generation either