Code Duplication    Length = 10-10 lines in 2 locations

omaha_server/crash/models.py 1 location

@@ 36-45 (lines=10) @@
33
34
from omaha.models import BaseModel
35
from omaha_server.utils import storage_with_spaces_instance
36
from crash.managers import CrashManager, SymbolsManager
37
38
39
def upload_to(directory, obj, filename):
40
    now = timezone.now()
41
    max_length = 255
42
    path = os.path.join(*map(str, [directory, now.year, now.month,
43
                                   now.day, uuid.uuid4(), filename]))
44
    if len(path) > max_length:
45
        name, ext = os.path.splitext(path)
46
        ext_length = len(ext)
47
        path = name[:max_length-ext_length] + ext
48
    return path

omaha_server/feedback/models.py 1 location

@@ 35-44 (lines=10) @@
32
from feedback.managers import FeedbackManager
33
34
35
def upload_to(directory, obj, filename):
36
    now = timezone.now()
37
    max_length = 100
38
    path = os.path.join(*map(str, [directory, now.year, now.month,
39
                                   now.day, uuid.uuid4(), filename]))
40
    if len(path) > max_length:
41
        name, ext = os.path.splitext(path)
42
        ext_length = len(ext)
43
        path = name[:max_length-ext_length] + ext
44
    return path
45
46
47
def screenshot_upload_to(obj, filename):