+ def get_source_sha1(self):
+ source_sha1 = self.source_sha1
+ if self.pk:
+ source_sha1 = type(self).objects.get(pk=self.pk).source_sha1
+ while source_sha1 == 'wait':
+ sleep(10)
+ if not source_sha1:
+ self.source_sha1 = 'wait'
+ if self.pk:
+ type(self).objects.filter(pk=self.pk).update(source_sha1='wait')
+ try:
+ f = open(force_bytes(self.source_file.path))
+ source_sha1 = sha1_file(f)
+ self.source_sha1 = source_sha1
+ if self.pk:
+ type(self).objects.filter(pk=self.pk).update(source_sha1=source_sha1)
+ except:
+ self.source_sha1 = ''
+ if self.pk:
+ type(self).objects.filter(pk=self.pk).update(source_sha1='')
+ return None
+ return source_sha1
+
+