Explorar o código

HUE-5225 [core] Prevent Oozie and Job Designer duplicate example documents from being installed

Jenny Kim %!s(int64=9) %!d(string=hai) anos
pai
achega
28a2a70adf
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      apps/oozie/src/oozie/management/commands/oozie_setup.py

+ 4 - 2
apps/oozie/src/oozie/management/commands/oozie_setup.py

@@ -155,13 +155,15 @@ class Command(NoArgsCommand):
           data.update({'content_type': doc.content_type.model, 'object_id': doc.object_id})
           data = json.dumps(data)
 
-          doc2 = Document2.objects.create(
+          # Don't overwrite
+          doc2, created = Document2.objects.get_or_create(
             owner=self.user,
             parent_directory=examples_dir,
             name=doc.name,
             type='link-workflow',
             description=doc.description,
-            data=data)
+            data=data
+          )
 
           LOG.info('Successfully installed sample link to jobsub: %s' % (doc2.name,))