Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-25068

Fix Download key in Blob.BulkDownload operation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 9.10, 10.1
    • Fix Version/s: 9.10-HF10, 10.2
    • Component/s: Automation
    • Release Notes Summary:
      The key generated for asynchronous downloads is ensured to be unique.
    • Tags:
    • Backlog priority:
      900
    • Sprint:
      nxcore 10.2.7
    • Story Points:
      5

      Description

      When requesting an asynchronous download using the Blob.BulkDownload, it generates a download key that will be used afterward to check the async download's status and download the blob when ready.
      The problem is the download key computation is based on the modification datetime of the blobs to include in the ZIP file and the user requesting the async download, which does not make the key unique if 2 (or more) async download requests for the same blob(s) are submitted simultaneously.

      How to reproduce:

      • Fire up a Nuxeo 9.10
      • create workspace /default-domain/workspaces/NXP-25068 and create 3 File documents in it named File1, File2, File3, with a different attached blob for each of them
      • unzip attached ZIP file NXP-25068.zip in a work directory
      • launch script NXP-25068_loop.sh

      The NXP-25068_loop.sh launches 10 simultaneous bulk downloads that should contain the 3 File documents created earlier.

      expected result: 10 ZIP files containing the blobs attached to the 3 File documents File1, File2 and File3 are created in the current directory.

      actual result: only a few ZIP files contain the blobs attached to the 3 File documents File1, File2 and File3, the other ZIP files are actually an HTML error page.

      The scripts require the tool jq to parse the JSON, you easily replace it with python command.

      The following modification solved the problem:

      diff --git a/nuxeo-features/nuxeo-automation/nuxeo-automation-core/src/main/java/org/nuxeo/ecm/automation/core/operations/blob/BulkDownload.java b/nuxeo-features/nuxeo-automation/nuxeo-automation-core/src/main/java/org/nuxeo/ecm/automation/core/operations/blob/BulkDownload.java
      index a95238f..c693f4c 100644
      --- a/nuxeo-features/nuxeo-automation/nuxeo-automation-core/src/main/java/org/nuxeo/ecm/automation/core/operations/blob/BulkDownload.java
      +++ b/nuxeo-features/nuxeo-automation/nuxeo-automation-core/src/main/java/org/nuxeo/ecm/automation/core/operations/blob/BulkDownload.java
      @@ -87,7 +87,7 @@ public class BulkDownload {
               }
               // Rendered documents might differ according to current user
               sb.append(session.getPrincipal().getName());
      -        return DigestUtils.md5Hex(sb.toString());
      +        return DigestUtils.md5Hex(sb.toString()) + new Long(System.currentTimeMillis()).toString();
           }
       
           @OperationMethod
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 4 hours
                1d 4h