Closed (fixed)
Project:
Acquia DAM
Version:
1.1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Jan 2026 at 20:54 UTC
Updated:
6 Aug 2026 at 06:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
becw commentedI originally reported this issue in acquia_dam 1.1.7, and half of the issue is still present as of acquia_dam 1.1.14.
Previously, both the new file and the old file remained both on the filesystem and as a Drupal file entity. Now, the existing Drupal file entity is updated with the new file, but the old file is still present on the filesystem (and no longer linked to a Drupal file entity).
I've updated the issue description to reflect the behavior as of acquia_dam 1.1.14.
Comment #3
becw commentedI've attached a patch that fixes the issue in my testing.
Comment #6
rajeshreeputraAssetFileEntityHelper changes:
Modified
updateExistingFile()to delete all files in the directory before writing the new file, using newdeleteDirectoryContents()helper handles the directory cleanup with a\UnexpectedValueExceptioncatch for the edge cases if any like directory does not present.This not only handles the filename-change orphan scenario but also cleans up any pre-existing orphaned files from before this fix was deployed.
Code coverage:
New test
testAssetFileReDownloadFilenameChange()inMediaIntegrationTest:a56fb261-8ad5-4e0d-8323-0e8a3659ed38with old versioned84ab8e-a822-471d-b2f4-21b7353e4d0c(filenamebobsCarsAgileExercisesOld.pdf) and new versione37312f5-e761-4ec4-92f2-8f0407f57bc7(filenamebobsCarsAgileExercisesNew.pdf)downloadFile,updateExistingFile, anddeleteDirectoryContentsComment #8
rajeshreeputraMR merged!