upload folder (unused files and duplicates)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick
    Member
    • Sep 2016
    • 46

    upload folder (unused files and duplicates)

    When a CRM user creates a post, stream, or a lead / account, s/he can upload pictures for the record, but after uploading, the CRM user may choose not to 'save' or 'update' the Record in question. (by clicking cancel or navigate to somewhere else)

    In this case, the uploaded files are already in the ESPOCRM/data/upload directory, but no record is going to use them.

    Are they automatically cleaned up by Cron job? or they just stay there cluttering the entire directory?


    Thank you in advance.
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello

    For now these files aren't deleted.

    In file application/Espo/Jobs/Cleanup.php change $collection definition in the method cleanupAttachments

    Code:
    $collection = $this->getEntityManager()->getRepository('Attachment')->where(array(
                'OR' => array(
                    array(
                        'role' => ['Export File']
                    ),
                    array(
                        'role' => 'Attachment',
                        'relatedId' => null,
                        'parentId' => null                    
                    )
                ),
                'createdAt<' => $dateBefore
            ))->limit(0, 100)->find();

    Comment

    • Patrick
      Member
      • Sep 2016
      • 46

      #3
      Thank you Tanya, I've made the modifications accordingly.

      Comment

      • Patrick
        Member
        • Sep 2016
        • 46

        #4
        its overwritten with each Espo Upgrade. Currently I'll just change it every time after upgrade.

        Comment

        • tanya
          Senior Member
          • Jun 2014
          • 4308

          #5
          You can develop own job, which will delete attachments without parent

          Comment

          • Patrick
            Member
            • Sep 2016
            • 46

            #6
            thank you Tanya,

            any entry-point on how to develop 'own job'?

            Comment

            • tanya
              Senior Member
              • Jun 2014
              • 4308

              #7
              There is a topic https://github.com/espocrm/documenta...heduled-job.md

              Comment

              Working...