Repository: pulp/pulpcore

Issue:
[PR #3886/596a72e4 backport][3.16] Taught PulpImport to recover from previously-failed attempt.
**This is a backport of PR #3886 as merged into main (596a72e4a12541304dcb8e23f7e1d3c5d8a58390).**

If an expected-reassembled-filename exists, ignore chunk-info and proceed with that file.

Test-coverage will be added in pulp_file once this is in a released version of pulpcore.

fixes #3737.
[nocoverage]


Discussion:

Resolving patch:
diff --git a/pulpcore/app/apps.py b/pulpcore/app/apps.py
--- a/pulpcore/app/apps.py
+++ b/pulpcore/app/apps.py
@@ -137,4 +137,4 @@ class PulpAppConfig(PulpPluginAppConfig):
     # The app label to be used when creating tables, registering models, referencing this app
     # with manage.py, etc. This cannot contain a dot and must not conflict with the name of a
     # package containing a Django app.
-    label = 'pulp_app'
+    label = 'core'
diff --git a/pulpcore/app/migrations/0001_initial.py b/pulpcore/app/migrations/0001_initial.py
--- a/pulpcore/app/migrations/0001_initial.py
+++ b/pulpcore/app/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.1.7 on 2019-03-07 15:19
+# Generated by Django 2.1.7 on 2019-03-11 09:42
 
 from django.conf import settings
 import django.core.validators
@@ -63,8 +63,8 @@ class Migration(migrations.Migration):
                 ('_created', models.DateTimeField(auto_now_add=True)),
                 ('_last_updated', models.DateTimeField(auto_now=True, null=True)),
                 ('relative_path', models.CharField(max_length=255)),
-                ('artifact', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='pulp_app.Artifact')),
-                ('content', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pulp_app.Content')),
+                ('artifact', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='core.Artifact')),
+                ('content', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Content')),
             ],
             bases=(models.Model, pulpcore.app.models.content.QueryMixin),
         ),
@@ -103,7 +103,7 @@ class Migration(migrations.Migration):
                 ('_last_updated', models.DateTimeField(auto_now=True, null=True)),
                 ('name', models.CharField(db_index=True, max_length=255, unique=True)),
                 ('base_path', models.CharField(max_length=255, unique=True)),
-                ('content_guard', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='distributions', to='pulp_app.ContentGuard')),
+                ('content_guard', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='distributions', to='core.ContentGuard')),
             ],
             options={
                 'default_related_name': 'distributions',
@@ -159,8 +159,8 @@ class Migration(migrations.Migration):
                 ('_created', models.DateTimeField(auto_now_add=True)),
                 ('_last_updated', models.DateTimeField(auto_now=True, null=True)),
                 ('relative_path', models.CharField(max_length=255)),
-                ('content_artifact', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='published_artifact', to='pulp_app.ContentArtifact')),
-                ('publication', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='published_artifact', to='pulp_app.Publication')),
+                ('content_artifact', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='published_artifact', to='core.ContentArtifact')),
+                ('publication', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='published_artifact', to='core.Publication')),
             ],
             options={
                 'default_related_name': 'published_artifact',
@@ -174,7 +174,7 @@ class Migration(migrations.Migration):
                 ('_last_updated', models.DateTimeField(auto_now=True, null=True)),
                 ('relative_path', models.CharField(max_length=255)),
                 ('file', models.FileField(max_length=255, upload_to=pulpcore.app.models.publication.PublishedMetadata._storage_path)),
-                ('publication', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='published_metadata', to='pulp_app.Publication')),
+                ('publication', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='published_metadata', to='core.Publication')),
             ],
             options={
                 'default_related_name': 'published_metadata',
@@ -231,8 +231,8 @@ class Migration(migrations.Migration):
                 ('sha256', models.CharField(max_length=64, null=True)),
                 ('sha384', models.CharField(max_length=96, null=True)),
                 ('sha512', models.CharField(max_length=128, null=True)),
-                ('content_artifact', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pulp_app.ContentArtifact')),
-                ('remote', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pulp_app.Remote')),
+                ('content_artifact', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.ContentArtifact')),
+                ('remote', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Remote')),
             ],
             bases=(models.Model, pulpcore.app.models.content.QueryMixin),
         ),
@@ -256,8 +256,8 @@ class Migration(migrations.Migration):
                 ('_id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                 ('_created', models.DateTimeField(auto_now_add=True)),
                 ('_last_updated', models.DateTimeField(auto_now=True, null=True)),
-                ('content', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='version_memberships', to='pulp_app.Content')),
-                ('repository', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pulp_app.Repository')),
+                ('content', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='version_memberships', to='core.Content')),
+                ('repository', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Repository')),
             ],
         ),
         migrations.CreateModel(
@@ -268,8 +268,8 @@ class Migration(migrations.Migration):
                 ('_last_updated', models.DateTimeField(auto_now=True, null=True)),
                 ('number', models.PositiveIntegerField(db_index=True)),
                 ('complete', models.BooleanField(db_index=True, default=False)),
-                ('base_version', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='versions', to='pulp_app.RepositoryVersion')),
-                ('repository', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='versions', to='pulp_app.Repository')),
+                ('base_version', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='versions', to='core.RepositoryVersion')),
+                ('repository', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='versions', to='core.Repository')),
             ],
             options={
                 'ordering': ('number',),
@@ -284,7 +284,7 @@ class Migration(migrations.Migration):
                 ('count_type', models.CharField(choices=[('A', 'added'), ('P', 'present'), ('R', 'removed')], max_length=1)),
                 ('content_type', models.TextField()),
                 ('count', models.IntegerField()),
-                ('repository_version', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='counts', to='pulp_app.RepositoryVersion')),
+                ('repository_version', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='counts', to='core.RepositoryVersion')),
             ],
         ),
         migrations.CreateModel(
@@ -312,7 +312,7 @@ class Migration(migrations.Migration):
                 ('finished_at', models.DateTimeField(null=True)),
                 ('non_fatal_errors', pulpcore.app.fields.JSONField(default=list)),
                 ('error', pulpcore.app.fields.JSONField(null=True)),
-                ('parent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='spawned_tasks', to='pulp_app.Task')),
+                ('parent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='spawned_tasks', to='core.Task')),
             ],
             options={
                 'abstract': False,
@@ -324,8 +324,8 @@ class Migration(migrations.Migration):
                 ('_id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                 ('_created', models.DateTimeField(auto_now_add=True)),
                 ('_last_updated', models.DateTimeField(auto_now=True, null=True)),
-                ('resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pulp_app.ReservedResource')),
-                ('task', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='pulp_app.Task')),
+                ('resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.ReservedResource')),
+                ('task', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.Task')),
             ],
             options={
                 'abstract': False,
@@ -365,72 +365,72 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='task',
             name='worker',
-            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tasks', to='pulp_app.Worker'),
+            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tasks', to='core.Worker'),
         ),
         migrations.AddField(
             model_name='reservedresource',
             name='tasks',
-            field=models.ManyToManyField(related_name='reserved_resources', through='pulp_app.TaskReservedResource', to='pulp_app.Task'),
+            field=models.ManyToManyField(related_name='reserved_resources', through='core.TaskReservedResource', to='core.Task'),
         ),
         migrations.AddField(
             model_name='reservedresource',
             name='worker',
-            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='pulp_app.Worker'),
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='core.Worker'),
         ),
         migrations.AddField(
             model_name='repositorycontent',
             name='version_added',
-            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='added_memberships', to='pulp_app.RepositoryVersion'),
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='added_memberships', to='core.RepositoryVersion'),
         ),
         migrations.AddField(
             model_name='repositorycontent',
             name='version_removed',
-            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='removed_memberships', to='pulp_app.RepositoryVersion'),
+            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='removed_memberships', to='core.RepositoryVersion'),
         ),
         migrations.AddField(
             model_name='repository',
             name='content',
-            field=models.ManyToManyField(related_name='repositories', through='pulp_app.RepositoryContent', to='pulp_app.Content'),
+            field=models.ManyToManyField(related_name='repositories', through='core.RepositoryContent', to='core.Content'),
         ),
         migrations.AddField(
             model_name='publication',
             name='publisher',
-            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='pulp_app.Publisher'),
+            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Publisher'),
         ),
         migrations.AddField(
             model_name='publication',
             name='repository_version',
-            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pulp_app.RepositoryVersion'),
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.RepositoryVersion'),
         ),
         migrations.AddField(
             model_name='progressreport',
             name='task',
-            field=models.ForeignKey(default=pulpcore.app.models.task.Task.current, on_delete=django.db.models.deletion.CASCADE, related_name='progress_reports', to='pulp_app.Task'),
+            field=models.ForeignKey(default=pulpcore.app.models.task.Task.current, on_delete=django.db.models.deletion.CASCADE, related_name='progress_reports', to='core.Task'),
         ),
         migrations.AddField(
             model_name='distribution',
             name='publication',
-            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='distributions', to='pulp_app.Publication'),
+            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='distributions', to='core.Publication'),
         ),
         migrations.AddField(
             model_name='distribution',
             name='publisher',
-            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='distributions', to='pulp_app.Publisher'),
+            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='distributions', to='core.Publisher'),
         ),
         migrations.AddField(
             model_name='distribution',
             name='repository',
-            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='distributions', to='pulp_app.Repository'),
+            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='distributions', to='core.Repository'),
         ),
         migrations.AddField(
             model_name='createdresource',
             name='task',
-            field=models.ForeignKey(default=pulpcore.app.models.task.Task.current, on_delete=django.db.models.deletion.CASCADE, related_name='created_resources', to='pulp_app.Task'),
+            field=models.ForeignKey(default=pulpcore.app.models.task.Task.current, on_delete=django.db.models.deletion.CASCADE, related_name='created_resources', to='core.Task'),
         ),
         migrations.AddField(
             model_name='content',
             name='_artifacts',
-            field=models.ManyToManyField(through='pulp_app.ContentArtifact', to='pulp_app.Artifact'),
+            field=models.ManyToManyField(through='core.ContentArtifact', to='core.Artifact'),
         ),
         migrations.CreateModel(
             name='ProgressBar',
@@ -440,7 +440,7 @@ class Migration(migrations.Migration):
                 'proxy': True,
                 'indexes': [],
             },
-            bases=('pulp_app.progressreport',),
+            bases=('core.progressreport',),
         ),
         migrations.CreateModel(
             name='ProgressSpinner',
@@ -450,7 +450,7 @@ class Migration(migrations.Migration):
                 'proxy': True,
                 'indexes': [],
             },
-            bases=('pulp_app.progressreport',),
+            bases=('core.progressreport',),
         ),
         migrations.AlterUniqueTogether(
             name='repositoryversion',
@@ -458,7 +458,7 @@ class Migration(migrations.Migration):
         ),
         migrations.AlterUniqueTogether(
             name='repositorycontent',
-            unique_together={('repository', 'content', 'version_added'), ('repository', 'content', 'version_removed')},
+            unique_together={('repository', 'content', 'version_removed'), ('repository', 'content', 'version_added')},
         ),
         migrations.AlterUniqueTogether(
             name='remoteartifact',
@@ -466,7 +466,7 @@ class Migration(migrations.Migration):
         ),
         migrations.AlterUniqueTogether(
             name='publishedmetadata',
-            unique_together={('publication', 'file'), ('publication', 'relative_path')},
+            unique_together={('publication', 'relative_path'), ('publication', 'file')},
         ),
         migrations.AlterUniqueTogether(
             name='publishedartifact',


Test patch: