missing file
[audio.git] / apps / archive / utils.py
1 from hashlib import sha1
2 from django.core.files.uploadedfile import UploadedFile
3
4
5 class ExistingFile(UploadedFile):
6
7     def __init__(self, path, *args, **kwargs):
8         self.path = path
9         return super(ExistingFile, self).__init__(*args, **kwargs)
10
11     def temporary_file_path(self):
12         return self.path
13
14     def close(self):
15         pass
16
17
18 def sha1_file(f):
19     sha = sha1()
20     for piece in iter(lambda: f.read(1024*1024), ''):
21         sha.update(piece)
22     return sha.hexdigest()