nextcloud / richdocuments

📑 Collabora Online for Nextcloud
https://nextcloud.com/collaboraonline
349 stars 115 forks source link

New document from default templates doesn't go via TemplateSource #2729

Closed thebearon closed 1 year ago

thebearon commented 1 year ago

Collabora Online supports creating new files based on templates, for this the CheckFileInfo response needs a TemplateSource property with the URL to the template (as it says here).

However, when files created from default templates, TemplateSource isn't used. See the following log snippets from coolwsd with CheckFileInfo JSON, and note how one doesn't include a TemplateSource entry.

To Reproduce

  1. Create eg. a personal template folder, specify it in the NC config, and add an OTT template to it,
  2. Create a new file based on this template,
  3. Create a new document based on the default empty template,
  4. Check the CheckFileInfo response in coolwsd logs for both cases.

Note that step 2 fails in richdocuments 7.0.2 due to #2697.

Server details

Nextcloud version: 25.0.2 Version of the richdocuments app 7.0.1 or so Version of Collabora Online 22.05.x

juliushaertl commented 1 year ago

We currently create new empty files by copying the empty file assets from https://github.com/nextcloud/richdocuments/tree/master/emptyTemplates since the file creating needs to be performed before calling Collabora. Would there be any benefit in still passing a TemplateSource in case of empty files?

One issue I noticed during reproducing #2697 was that Collabora seems to fail creating a odt file from a dotx template, so I assume we would need either separate template files or a fix in Collabora to make creating files from templates of different types possible. Is that a known limitation?

thebearon commented 1 year ago

We currently create new empty files by copying the empty file assets from https://github.com/nextcloud/richdocuments/tree/master/emptyTemplates since the file creating needs to be performed before calling Collabora. Would there be any benefit in still passing a TemplateSource in case of empty files?

@kendy, what is your take on this?

One issue I noticed during reproducing #2697 was that Collabora seems to fail creating a odt file from a dotx template, so I assume we would need either separate template files or a fix in Collabora to make creating files from templates of different types possible. Is that a known limitation?

I checked this with a DOTX template in a local build, and had no problem with creating an ODT file based on it. Is there a sample DOTX you could share?

juliushaertl commented 1 year ago

I've seen this with the following two template files added to the user template directory when testing with #2740

Test.dotx.zip presentation.potx.zip

TemplateSource is set, attached the coolwsd.log for that attempt where it seems the template file is properly downloaded

coolwsd.log

kendy commented 1 year ago

We currently create new empty files by copying the empty file assets from https://github.com/nextcloud/richdocuments/tree/master/emptyTemplates since the file creating needs to be performed before calling Collabora. Would there be any benefit in still passing a TemplateSource in case of empty files?

@kendy, what is your take on this?

The befit as I see it is that there would be just 1 code path that is used for creating files; so it would be much easier to spot problems with file creation - as it would appear already here.

Having said that, I suppose you cannot remove the "copy & then open" functionality from Nextcloud, as you are using that also for other file templates, like the .md and others - so I don't think it is necessary to change to the TemplateSource way of creating files here.

juliushaertl commented 1 year ago

Yes, we will always have to copy a file due to the way Nextcloud file creation is structured so let's close this.