core icon indicating copy to clipboard operation
core copied to clipboard

Avoid empty file creation via WebDAV when using Finder

Open dsilvam opened this issue 10 years ago • 6 comments

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)

  1. Set up WebDAV with Finder. See here for detailed instructions.
  2. Upload a File
  3. 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.

dsilvam avatar Oct 20 '16 17:10 dsilvam

PR https://github.com/dotCMS/core/pull/10052

erickgonzalez avatar Nov 02 '16 19:11 erickgonzalez

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

wezell avatar Nov 02 '16 21:11 wezell

Eric I just pushed a possible fix - can you test this?

wezell avatar Nov 02 '16 21:11 wezell

sure Will going to test it in a few minutes

erickgonzalez avatar Nov 02 '16 21:11 erickgonzalez

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.

erickgonzalez avatar Nov 02 '16 23:11 erickgonzalez

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

shaydotcms avatar Nov 08 '16 20:11 shaydotcms