Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload cache fixes #439

Open
wants to merge 18 commits into
base: dev
Choose a base branch
from
Open

Upload cache fixes #439

wants to merge 18 commits into from

Commits on Apr 27, 2023

  1. Upload cache fixes

    This mod fixes the following upload cache problems:
    
    (1)
    If one uploads many files (dropping files test0.bin-test9.bin in one move) races may occur and file id in DOM won't match file ids in web upload dir on server, i.e.:
    
    ```
    $(".AttachmentListContainer tbody tr").filter(function() { console.log("%s, %d", $(this).find('td.Filename').text(), $(this).find('a').data('file-id'))})
    test9.bin, 10
    test8.bin, 8
    test7.bin, 8
    test6.bin, 7
    test5.bin, 4
    test4.bin, 5
    test3.bin, 3
    test2.bin, 3
    test1.bin, 2
    test0.bin, 1
    ```
    
    This may be fixed with patch (which unblocks updating all file ids on upload not just for one file)...
    
    ```
    --- a/var/httpd/htdocs/js/Core.UI.js   2021-11-08 18:53:34.088284466 +0100
    +++ b/var/httpd/htdocs/js/Core.UI.js 2021-12-16 18:41:14.090199778 +0100
    @@ -697,10 +697,6 @@
    
                                     $TargetObj = $ExistingItemObj.closest('tr');
    
    -                                if ($TargetObj.find('a').data('file-id')) {
    -                                    return;
    -                                }
    -
                                     $TargetObj
                                         .find('.Filetype')
                                         .text(Attachment.ContentType)
    ```
    
    ...but using file ids for identification of uploaded files is not race condition resistant; to provoke race condition apply patch
    
    ```
    --- a/Kernel/Modules/AjaxAttachment.pm 2021-06-19 21:59:34.379471088 +0200
    +++ b/Kernel/Modules/AjaxAttachment.pm       2021-12-16 18:38:28.943925139 +0100
    @@ -56,6 +56,10 @@
                 Param => 'Files',
             );
    
    +        if ($UploadStuff{Filename} eq 'test01.bin') {
    +            sleep(1);
    +        }
    +
             $UploadCacheObject->FormIDAddFile(
                 FormID      => $Self->{FormID},
                 Disposition => 'attachment',
    @@ -67,6 +71,10 @@
                 FormID => $Self->{FormID},
             );
    
    +        if ($UploadStuff{Filename} eq 'test02.bin') {
    +            sleep(2);
    +        }
    +
             my @AttachmentData;
    ```
    
    and drop files test01.bin and test02.bin (same size) in one move; after upload there will be:
    
    ```
    $(".AttachmentListContainer tbody tr").filter(function() { console.log("%s, %d", $(this).find('td.Filename').text(), $(this).find('a').data('file-id'))})
    test02.bin, 1
    test01.bin, 1
    ```
    
    not
    
    ```
    test02.bin, 2
    test01.bin, 1
    ```
    
    This problem was solved by removing unnecessarry FileID attribute from upload data struct to avoid any races that may occurr between filename list and fileid list. Only filename will be used to identify items added to upload cache.
    
    (2)
    Double clicking trash icon to remove attachment generates two requests to server and one will cause an error.
    
    (3)
    Web form is not removed from upload cache dir after saving or updating template.
    
    (4)
    Unused upload handling code removed.
    
    Author-Change-Id: IB#1113065
    pboguslawski committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    cfac9c5 View commit details
    Browse the repository at this point in the history
  2. Upload cache fixes

    Added missing part of 6e42dbb.
    
    Fixes: 6e42dbb
    Author-Change-Id: IB#1113065
    pboguslawski committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    0a128e0 View commit details
    Browse the repository at this point in the history
  3. Code policy cleanups

    Code policy cleanups.
    
    Fixes: 6e42dbb
    Author-Change-Id: IB#1113065
    pboguslawski committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    3b6d9f5 View commit details
    Browse the repository at this point in the history
  4. Syntax fixed

    Fixes: 6e42dbb
    Author-Change-Id: IB#1113065
    pboguslawski committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    dc1a521 View commit details
    Browse the repository at this point in the history
  5. Upload cache directory removal undone

    Will be moved to separate issue.
    
    Fixes: 53a7ba6
    Author-Change-Id: IB#1113065
    pboguslawski committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    a29118c View commit details
    Browse the repository at this point in the history
  6. FileID parameters removed from comments

    Fixes: 6e42dbb
    Author-Change-Id: IB#1113065
    pboguslawski committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    4e98dd6 View commit details
    Browse the repository at this point in the history
  7. Fixed merge rel-6_0-IB#1113065 into rel-6_0-ib

    Parameter name regression fixed.
    
    Fixes: 2d608b05303537e10c75a453f941026e58c2b9eb
    Author-Change-Id: IB#1113065
    pboguslawski committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    55dd3b6 View commit details
    Browse the repository at this point in the history
  8. Variable name fixed and code policy fixes

    Author-Change-Id: IB#1113065
    pboguslawski committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    6a04fa6 View commit details
    Browse the repository at this point in the history

Commits on May 19, 2023

  1. Update CHANGES.md

    pboguslawski authored May 19, 2023
    Configuration menu
    Copy the full SHA
    e478ddf View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ff763e0 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8520688 View commit details
    Browse the repository at this point in the history
  4. Update FormDraft.pm

    pboguslawski authored May 19, 2023
    Configuration menu
    Copy the full SHA
    4f47aee View commit details
    Browse the repository at this point in the history
  5. Update UploadCache.pm

    pboguslawski authored May 19, 2023
    Configuration menu
    Copy the full SHA
    72a6292 View commit details
    Browse the repository at this point in the history
  6. Update DB.pm

    pboguslawski authored May 19, 2023
    Configuration menu
    Copy the full SHA
    531ebdd View commit details
    Browse the repository at this point in the history
  7. Update FS.pm

    pboguslawski authored May 19, 2023
    Configuration menu
    Copy the full SHA
    2bd8966 View commit details
    Browse the repository at this point in the history
  8. Update WebUploadCache.t

    pboguslawski authored May 19, 2023
    Configuration menu
    Copy the full SHA
    16b0d01 View commit details
    Browse the repository at this point in the history
  9. Update Core.AJAX.js

    pboguslawski authored May 19, 2023
    Configuration menu
    Copy the full SHA
    e5d1f9c View commit details
    Browse the repository at this point in the history
  10. Update Core.UI.js

    pboguslawski authored May 19, 2023
    Configuration menu
    Copy the full SHA
    ef39238 View commit details
    Browse the repository at this point in the history