Repository: pulp/pulpcore

Issue:
File System Exporter ignores start_repository_version and exports everything for pass-through publications 
**Version**
Please provide the versions of the pulpcore and plugin packages in use, and how they are installed.  If you are using Pulp via Katello, please provide the Katello version.
Pulp 3.18 and later

**Describe the bug**
The file system exporter ignores start_repository_version and exports everything for pass-through publications. So FilePublications for example are marked as pass_through publications. The export task in this case seems to ignore the start_repository_version and dumps everything over. 

Note: If you gave it a repo version and start_repo version it returns the right content . This behavior is only when pass a publication and a start_repo_version (which is what Katello uses).


**To Reproduce**
Steps to reproduce the behavior:

- Have a file repo with multiple versions and publications (make sure the versions have some new files)
- Try to export this repo via the file system exporter and provide a publication and start_version 

**Expected behavior**
Exported content should have the published_metadata + difference in content i.e. publication.repository_version.content - start_repository_version.content  

** Actual **
Everything gets copied.

Bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=2172564



Discussion:

Resolving patch:
diff --git a/pulpcore/app/tasks/export.py b/pulpcore/app/tasks/export.py
--- a/pulpcore/app/tasks/export.py
+++ b/pulpcore/app/tasks/export.py
@@ -113,7 +113,6 @@ def _export_publication_to_file_system(
         path (str): Path to place the exported data
         publication_pk (str): Publication pk
     """
-    difference_content_artifacts = []
     content_artifacts = ContentArtifact.objects.filter(
         pk__in=publication.published_artifact.values_list("content_artifact__pk", flat=True)
     )
@@ -121,11 +120,6 @@ def _export_publication_to_file_system(
         start_version_content_artifacts = ContentArtifact.objects.filter(
             artifact__in=start_repo_version.artifacts
         )
-        difference_content_artifacts = set(
-            content_artifacts.difference(start_version_content_artifacts).values_list(
-                "pk", flat=True
-            )
-        )
 
     if publication.pass_through:
         content_artifacts |= ContentArtifact.objects.filter(
@@ -136,11 +130,20 @@ def _export_publication_to_file_system(
         # In some cases we may want to disable this validation
         _validate_fs_export(content_artifacts)
 
+    difference_content_artifacts = []
+    if start_repo_version:
+        difference_content_artifacts = set(
+            content_artifacts.difference(start_version_content_artifacts).values_list(
+                "pk", flat=True
+            )
+        )
+
     relative_path_to_artifacts = {}
     if publication.pass_through:
         relative_path_to_artifacts = {
             ca.relative_path: ca.artifact
             for ca in content_artifacts.select_related("artifact").iterator()
+            if (start_repo_version is None) or (ca.pk in difference_content_artifacts)
         }
 
     for pa in publication.published_artifact.select_related(


Test patch: