Bug 12818

Summary: Remove orphaned imported layers when project is deleted
Product: [Build System, Metadata & Runtime] Toaster Reporter: David Reyna <david.reyna>
Component: toasterAssignee: David Reyna <david.reyna>
Status: RESOLVED FIXED QA Contact: Toaster default assignee <toaster>
Severity: normal    
Priority: Medium CC: jessica.zhang, stanciux.mihail
Version: unspecified   
Target Milestone: 2.6 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description David Reyna 2018-06-28 00:31:39 UTC
Imported layers are indirectly attached to projects via a Layer_Version record.

When a delete is performed on a project, Django will perform the deep delete on all related records, but it cannot find these related imported layer objects. This results in orphaned layers that can block re-adding that layer subsequently (because names must be unique).

The project delete method needs to capture those layers to delete before the project is deleted, and then explicitly delete then (as long as they are not referenced by other projects).
Comment 1 David Reyna 2018-08-26 05:54:42 UTC
commit 08fbdc02e32d715ae94e3b9603fb3ec8351c8fd3