Jared Hancock
authored
If a file is attached via email and sent into the system, and a file is on record with the same signature (hash) and size, the system will not save the file. Instead, the key of the existing file would be found and used instead. This patch fixes a bug in AttachmentFile::save. The key was generated for the new file; however, if it was determined to be a duplicate, the key of the existing file was not returned. Therefore generated key, which wasn't saved to the database, was returned. Therefore, the wrong key was placed in the body of the message with cid:<key> for inline images, although that key would not exist in the database. This patch correctly returns the existing key from the ::save() method for de-duplicated files.