]> git.parisson.com Git - timeside.git/commitdiff
Add sha1sum to item
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 4 Apr 2014 07:56:22 +0000 (09:56 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 4 Apr 2014 07:56:22 +0000 (09:56 +0200)
timeside/models.py

index 4cfdea881118421405880fdf14d9e84ae00fa5af..1e351605f22334a5f75e3eee8207f46dd7d17fc7 100644 (file)
@@ -3,6 +3,7 @@
 import timeside, os, uuid, time, hashlib, mimetypes
 
 from timeside.analyzer.core import AnalyzerResultContainer, AnalyzerResult
+from timeside.decoder.utils import sha1sum_file
 
 from django.db import models
 from django.utils.translation import ugettext_lazy as _
@@ -92,9 +93,10 @@ class Item(DocumentedBaseResource):
 
     def save(self, **kwargs):
         if self.file:
-            self.mime_type = get_mime_type(self.file.path)
-        if not self.sha1:
-            pass
+            if not self.mime_type:
+                self.mime_type = get_mime_type(self.file.path)
+            if not self.sha1:
+                self.sha1 = sha1sum_file(self.file)
         super(Item, self).save(**kwargs)
 
     def results(self):