U4-9919 - Updated media files are deleted

Created by Brian Powell 16 May 2017, 03:01:50 Updated by Shannon Deminick 24 May 2017, 05:51:38

Subtask of: U4-9609

In 7.6.1, when I try to update an existing media file, it seems that the file just gets deleted on disk. I've seen this with two instances, one upgraded from 7.5.13 and the other from 7.5.11.

To replicate the issue, in Media view in the backend, go to an existing file. Using the file selector, browse for a new file to upload and save changes. Umbraco will report that the file was successfully uploaded and saved without errors, but if you check the folder on disk, it is empty. This happens both with media items that existed before the 7.6.1 upgrade and those that predate it.

If I create a brand new media item, the file is saved. If I "Remove File" on an existing item and then upload the new file, it's saved. The problem only shows up when trying to update an existing file.

My file permissions all seem to be in order. I ran Process Monitor and it shows the file being written but the Delete flag is set so that the file is thrown away when the write is completed.

2 Attachments


Sebastiaan Janssen 16 May 2017, 06:06:26

Can you explain where the file selector is once you've uploaded a file? I don't see it.

Brian Powell 16 May 2017, 12:15:43

@sebastiaan I'm seeing this with non-image files (media type: File). When I look at the media type, it says the upload area is of type Umbraco.UploadField.

Brian Powell 16 May 2017, 12:18:19

@sebastiaan I'm seeing this with non-image files (media type: File). When I look at the media type, it says the upload area is of type Umbraco.UploadField.

Sebastiaan Janssen 16 May 2017, 12:34:11

Aha! I see what it's doing now, if you replace the file with a file with the same name, gotcha, can reproduce.

Claus Jensen 18 May 2017, 09:38:44

In here we check the the existing files vs. the newly uploaded file and make sure to delete ones we no longer need/want. https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs#L133-L134

The media filesystem however returned the file path in the format idfolder\\filename.jpg due to use of Path.Combine() which doesn't correspond to the path format we really want to be using: idfolder/filename.jpg.

  • Fixed the media filesystem's GetMediaPath to return the correctly formatted path and that solves the delete issue.

  • Also had to fix the file upload value editor since it would not refresh the UI view unless the file name had actually changed. This wouldn't happen when reuploading a new file with the same name to the server.

  • Few formatting/cleanup fixes in related files.

PR: https://github.com/umbraco/Umbraco-CMS/pull/1951

Shannon Deminick 19 May 2017, 03:20:03

Can confirm the PR fixes the issue

Priority: Task - Pri 1

Type: Bug

State: Fixed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.6.1

Due in version: 7.6.2


Story Points:

Cycle: 1