Patch #26622

Copy version attachments (i.e. Files) along with the versions on project copy

Added by Holger Just 4 months ago. Updated 3 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Projects
Target version:4.1.0

Description

When copying a project and opting to also copy versions, the attached files (i.e. the content of the "Files" tab of the source project) is not copied along.

The attached patch fixes this and also copies the version attachments.

0002-Copy-version-attachments-i.e.-Files-along-with-the-v.patch Magnifier (1.92 KB) Holger Just, 2017-08-04 18:55

0003-Copy-project-attachments.patch Magnifier (1.68 KB) Holger Just, 2017-08-04 18:59

modules-to-copy@2x.png (20.5 KB) Go MAEDA, 2017-08-05 09:18

0004-Clarify-that-copying-versions-with-a-project-also-co.patch Magnifier (3.08 KB) Holger Just, 2017-08-09 10:47

copy_files_and_versions.png (36.6 KB) Holger Just, 2017-08-09 10:52

History

#1 Updated by Holger Just 4 months ago

Turns out, there was a slight bug in the tests. Attached is the working patch. The first version can be deleted / disregarded.

#2 Updated by Holger Just 4 months ago

Similarly to the version attachments, it is also possible to upload files directly to a project in the Files tab. We should always copy those attachments along. This is implemented by the attached patch.

Since we are deduplicating attachments in disk already, copying these attachments is basically free anyways.

#3 Updated by Jan from Planio www.plan.io 4 months ago

  • File deleted (0001-Copy-version-attachments-i.e.-Files-along-with-the-v.patch)

#4 Updated by Jan from Planio www.plan.io 4 months ago

  • Target version set to Candidate for next minor release

#5 Updated by Go MAEDA 4 months ago

I think it would be better to have a checkbox like as follows on ProjectsController#copy page. Maybe users sometimes exclude Files module when they copy a project.

#6 Updated by Holger Just 3 months ago

This could easily work for file directly attached to the project.

For files attached to versions, we can only copy them if the versions are also copied to have a valid reference. Besides this not fitting well into the existing code, we would then have to find a way to handle people opting to copy files but not versions.

The simplest solution could be do not copy version-attached files in that case (which would probably be surprising for people not being accustomed to the details of Redmine's data model). Alternatively, we could also try to enforce the selection on the UI with javascript (but would still have to handle this somehow on the server anyway). In any case, I'm afraid this gets out of hand pretty quickly implementation-wise...

Maybe, we can just improve the wording so show

[ ] Versions (2) and Files

instead of only

[ ] Versions (2)

today.

What do you think?

#7 Updated by Go MAEDA 3 months ago

I think it is confusing to always copy files along with versions for ordinary users because many users don't know the data structure of Redmine.

Besides, it is very problematic when there are dozens of files in the Files module and the user don't want to copy those files. The user have to click the trash icon dozens of times to delete all files after copying a project.

In my opinion, we should implement a feature to delete multiple files at once in Files module when this patch is merged.

#8 Updated by Holger Just 3 months ago

Go MAEDA wrote:

In my opinion, we should implement a feature to delete multiple files at once in Files module when this patch is merged.

Absolutely, that in itself is a good idea, regardless of whether this patch is merged or not.

Still, right now there is no way to copy the files along with a project. To maintain consistency with all the other objects being copied, we should make sure to also copy attachments in all cases along with their parent objects.

Given that the most common use-case for copying projects is to create a new copy of a template project (rather than random copies of existing heavily-used projects), I think it's not that suprising that files are also copied along. Yes, the data structure is non-obvious to most users (along with the general distinction between "Files" and "Documents"), hence my proposal to change the wording to make it at least obvious what is happening when the checkbox is enabled.

#9 Updated by Go MAEDA 3 months ago

  • Target version changed from Candidate for next minor release to 4.1.0

Holger, thank you for your explanation. I have agreed with your opinion that the common use case of this feature is to copy a template project after reading #26622#note-8.

hence my proposal to change the wording to make it at least obvious what is happening when the checkbox is enabled.

It makes sense. I am setting target version to 4.1.0. Could you attach a patch to change the wording?

#10 Updated by Holger Just 3 months ago

Thank you Maeda-san. I have attached a patch to change the wording for English and German. The copy project screen now looks like this (with the patch from #26621 applied):

Also available in: Atom PDF