Review main Merged

70820[FEATURE] Allow to download files from file list directly

Benni Mack CR +2 V +2 Hard +375 −5 updated 09/01/21, 09:29

Commit message

This change adds a new button to all files and folders
to directly download a specific file from the file list
or the context menu.

In case a folder or multiple files/folders are selected,
a zip file is created on-the-fly.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Benjamin Franzke +1
    • Oli Bartsch +1
  • Verified V +2 Done
    • Benni Mack +2
    • Benjamin Franzke +1
    • Oli Bartsch +1
    • core-ci +1 CI

Issues 1

Files 16

Review log 3753

Show 1828 earlier messages
  1. Benni Mack uploaded patch set 1 08/30/21, 09:28

  2. Benjamin Franzke commented on patch set 1 08/30/21, 09:33

    FileDownloadController.php:69

    Yes, or it could use our SelfEmittableLazyOpenStream. See typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php
  3. Benjamin Franzke commented on patch set 1 08/30/21, 09:36

    FileDownloadController.php:69 Reply

    Well, no, bad idea, as we'd want the tmpfile to be deleted at some point… :\
  4. Benni Mack commented on patch set 1 08/30/21, 09:37

    FileDownloadController.php:69 Reply

    Didn't get it working with \ZipArchive and a stream in another way :(
  5. core-ci voted on patch set 1 V -1 08/30/21, 09:43 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15847

  6. Benni Mack uploaded patch set 2 08/30/21, 15:45

  7. core-ci voted on patch set 2 V -1 08/30/21, 16:03 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15880

  8. Benni Mack uploaded patch set 3 08/30/21, 16:21

  9. core-ci voted on patch set 3 V -1 08/30/21, 16:34 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15883

  10. Benni Mack uploaded patch set 4 08/30/21, 16:53

  11. core-ci voted on patch set 4 V -1 08/30/21, 17:09 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15885

  12. Benni Mack uploaded patch set 5 08/30/21, 17:44

  13. core-ci voted on patch set 5 V -1 08/30/21, 18:03 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15888

  14. Benni Mack uploaded patch set 6 08/30/21, 18:04

  15. core-ci voted on patch set 6 V +1 08/30/21, 18:18 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15890

  16. Oli Bartsch uploaded patch set 7 08/30/21, 23:40

  17. core-ci voted on patch set 7 V +1 08/30/21, 23:55 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15899

  18. Benjamin Franzke commented on patch set 7 08/31/21, 04:26

    FileDownloadController.php:65

    We should delete the tmpfile after creating the response.
  19. Oli Bartsch uploaded patch set 8 08/31/21, 10:23

  20. Oli Bartsch commented on patch set 8 V +1 CR +1 08/31/21, 10:39

    FileDownloadController.php:65 Reply

    Done
  21. core-ci voted on patch set 8 V -1 08/31/21, 10:41 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15920

  22. core-ci voted on patch set 8 V +1 08/31/21, 11:00 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15920

  23. Benjamin Franzke commented on patch set 8 CR -1 08/31/21, 11:59

    Well, actually a zip file is also generated if only one file is selected, right? Would that be much effort to avoid zip file generation in that case as well?

    FileList.ts:225

    fileName might be null. (e.g. in case an error occured, then the header Content-Disposition might not be available) Example for an error (if the filesize is larger than server memory limit): <br /> <b>Fatal error</b>: Allowed memory size of 134217728 bytes exhausted (tried to allocate 209757528 bytes) in <b>[…]/typo3/sysext/filelist/Classes/Controller/FileDownloadController.php</b> on line <b>81</b><br />

    FileList.ts:228

    Hm.. So I guess this is taken from https://stackoverflow.com/a/9834261/4223467 The curlpit is: Even if we generate a 200MB zip, this will now be stored in memory. Not nice, but I didn't experience problems on my fast pc right now, don't know though how PCs with limited memory will like this…

    FileDownloadController.php:48

    We need to check whether items is empty. Will then result into a PHP WARNING if empty: PHP Warning: file_get_contents(/tmp/php4y3k0m): failed to open stream: No such file or directory in […]/typo3/sysext/filelist/Classes/Controller/FileDownloadController.php line 81
  24. Oli Bartsch uploaded patch set 9 08/31/21, 14:58

  25. Oli Bartsch commented on patch set 9 08/31/21, 15:03

    Reply

    This is only the case if the "multi record selection action" is used. For this case it's IMO fine since this action should be used for multiple files/folders. Single download can be achieved via the actions in context menu / secondary menu. It's furthermore not that easy to achieve since there is only one array "filesAndFolders" to keep the correct order. We sure could check after preparing this array if its length is one, but we then still don't know if it's a file or a folder, since only the identifier is stored as value.

    FileList.ts:225 Reply

    Done

    FileDownloadController.php:48 Reply

    Done
  26. core-ci voted on patch set 9 V +1 08/31/21, 15:28 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15949

  27. Oli Bartsch voted on patch set 9 V +1 CR +1 08/31/21, 15:29

  28. Benjamin Franzke uploaded patch set 10 09/01/21, 06:36

  1. Benjamin Franzke commented on patch set 10 09/01/21, 06:38

    Reply

    Ack

    FileList.php:1003

    Would be nice if the download-cell-actions would be handled by javascript as well: a) …to show nprogress b) to check for possible errors in order to present a Notification (instead of currently an error in the iframe) …but that not strictly required and not wrong right now, therefore I consider that optional.
  2. core-ci voted on patch set 10 V +1 09/01/21, 06:51 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15981

  3. Oli Bartsch voted on patch set 10 V +1 CR +1 09/01/21, 07:13

  4. Benjamin Franzke commented on patch set 10 CR -1 09/01/21, 07:14

    temporary CR-1 as Helmut would like to take a quick look.

    FileList.php:1003

    @Helmut: Fine with this?
  5. Helmut Hummel commented on patch set 10 CR -1 09/01/21, 07:24

    FileList.php:1003 Reply

    Nooe. Please remove the call to PathUtility here. It is not required any more since FAL Urls are now always absolute
  6. Benni Mack commented on patch set 10 CR -1 09/01/21, 08:05

    on it
  7. Benni Mack uploaded patch set 11 09/01/21, 08:15

  8. Benni Mack uploaded patch set 12 09/01/21, 08:24

  9. Benni Mack commented on patch set 12 09/01/21, 08:24

    ready to review
  10. Benni Mack uploaded patch set 13 09/01/21, 08:26

  11. core-ci voted on patch set 11 V +1 09/01/21, 08:32 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15985

  12. Benjamin Franzke commented on patch set 13 V -1 09/01/21, 08:35

    Sorry, one thin left: It fails to download empty folders: PHP Warning: file_get_contents(/tmp/phpcz7zQT): failed to open stream: No such file or directory in /home/ben/src/TYPO3.CMS/typo3/sysext/filelist/Classes/Controller/FileDownloadController.php line 88
  13. Benni Mack uploaded patch set 14 09/01/21, 08:40

  14. core-ci voted on patch set 12 V +1 09/01/21, 08:43 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15987

  15. core-ci voted on patch set 14 V -1 09/01/21, 08:43 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15989

  16. core-ci voted on patch set 13 V -1 09/01/21, 08:47 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15988

  17. Benjamin Franzke commented on patch set 13 09/01/21, 08:48

    Reply

    See https://www.php.net/manual/en/ziparchive.close.php#78667 > Don't forget to check the zip isn't empty, folks - otherwise the zip won't be created at all, and the server will issue no warning! So we probably need to count the files that have been added. Or – even better, also add empty directories via ZipArchive::addEmptyDir – but that'd require quite a rewrite of the recursive-file-iterator.

    FileList.php:996

    jsonEncodeForHtmlAttribute doesn't work here. causes: "1:/introduction/" to be outputted as: "1:\/introduction\/" then the download of course files. So we should use htmlspecialchars here.
  18. Benjamin Franzke uploaded patch set 15 09/01/21, 08:56

  19. Benjamin Franzke commented on patch set 15 09/01/21, 08:56

    FileDownloadController.php:75

    ^^ $zipFileName has not be created at this point, so need to unlink – otherwise it'll fail with PHP Warning: unlink(/tmp/phpI9vGDe): No such file or directory in /home/ben/src/TYPO3.CMS/typo3/sysext/filelist/Classes/Controller/FileDownloadController.php line 75

    FileList.php:996 Reply

    Done
  20. Benjamin Franzke commented on patch set 15 09/01/21, 08:57

    FileDownloadController.php:75 Reply

    Done
  21. Benjamin Franzke commented on patch set 15 09/01/21, 08:57

    FileList.php:1003 Reply

    Done

    FileList.php:1003 Reply

    Done
  22. core-ci voted on patch set 15 V +1 09/01/21, 09:14 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15992

  23. Oli Bartsch voted on patch set 15 V +1 CR +1 09/01/21, 09:25

  24. Benni Mack commented on patch set 15 V +2 CR +2 09/01/21, 09:29

    Thanks for making sure this feature is OK
  25. Benni Mack merged patch set 16 09/01/21, 09:29