orbeon / orbeon-forms

Orbeon Forms is an open source web forms solution. It includes an XForms engine, the Form Builder web-based form editor, and the Form Runner runtime.
http://www.orbeon.com/
GNU Lesser General Public License v2.1
514 stars 221 forks source link

Save operation completes before all files are uploaded in Multiple File Attachments control #6548

Open avernet opened 1 week ago

avernet commented 1 week ago

To reproduce:

Result:

+1 from customer

ebruchez commented 2 days ago

Right now, the XFCD keeps a pendingUploads set . This is:

Now, in the case of a multiple file upload, each upload is sent separately on the client. We have a processFileList() function
based on Future which sends each file at at time using addFile().

So it is possible that the save-final() process, which uses the pending-uploads, catches pendingUploads just at a time between two uploads of a multiple-upload sequence. Ideally, this shouldn't happen, and save-final() should not be allowed to proceed.

Note that this could also happen in even with separate upload controls. So the client should somehow be able to tell the server whether there are pending uploads on the client.

ebruchez commented 2 days ago

The client keeps a pending uploads queue in UploaderClient. Sequence of events:

One difficulty is to make sure the client and the server are synchronized. You don't want, for example, the client to tell the server that 3 uploads are expected, 1 upload completes, the client somehow is interrupted, and the server forever expects 2 more uploads, while the client no longer knows about it.

Adding files to the queue, even though it is based on Future, allows, at least in "online" mode, to fill the pending uploads queue as uploads are added. So at the end of an upload, we know if there are pending uploads on the client. Could we, at the same time we send xxforms-upload-done or xxforms-upload-error to the server, send a new xxforms-upload-start just before that?

Q: What happens with xxforms-upload-start/xxforms-upload-done in the case of multiple file uploads? Are they dispatched to the same XForms control, or different ones?

ebruchez commented 1 day ago

So, attachment.xbl has a single xf:upload, which uploads to the local instance. Upon xxforms-upload-done, it copies over the the data as appropriate.

So, in the case of a multiple attachments control, it doesn't quite make sense from a sequence point of view to dispatch xxforms-upload-start before xxforms-upload-done or xxforms-upload-error, does it? We'd like the start/done|error to be paired. In addition, the id will be added to the list of pending uploads, and the subsequent done|error will remove it. So It think that option will not work.