summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Mekin <amekin@crystalnix.com>2016-10-04 18:53:24 +0600
committerAndrey Mekin <amekin@crystalnix.com>2016-10-05 18:20:21 +0600
commit8fa6d6a11e122834d13d4a81f4973e0f390be56b (patch)
tree1c69009b93e3b2e504e05e6aa778ce1e7ba3e57e
parentb2907055db8037ef0701fc10b5a0fb865fd82afd (diff)
downloadomaha-server-8fa6d6a11e122834d13d4a81f4973e0f390be56b.zip
omaha-server-8fa6d6a11e122834d13d4a81f4973e0f390be56b.tar.gz
omaha-server-8fa6d6a11e122834d13d4a81f4973e0f390be56b.tar.bz2
Reduce filenames of file fields of models Crash and Feedback
-rw-r--r--omaha_server/crash/models.py18
-rw-r--r--omaha_server/feedback/models.py10
2 files changed, 22 insertions, 6 deletions
diff --git a/omaha_server/crash/models.py b/omaha_server/crash/models.py
index 434b26a..d7a4dd0 100644
--- a/omaha_server/crash/models.py
+++ b/omaha_server/crash/models.py
@@ -33,16 +33,24 @@ from omaha.models import BaseModel
from crash.managers import CrashManager, SymbolsManager
-def crash_upload_to(obj, filename):
+def upload_to(directory, obj, filename):
now = timezone.now()
- return os.path.join(*map(str, ['minidump', now.year, now.month,
+ max_length = 255
+ path = os.path.join(*map(str, [directory, now.year, now.month,
now.day, uuid.uuid4(), filename]))
+ if len(path) > max_length:
+ name, ext = os.path.splitext(path)
+ ext_length = len(ext)
+ path = name[:max_length-ext_length] + ext
+ return path
+
+
+def crash_upload_to(obj, filename):
+ return upload_to('minidump', obj, filename)
def crash_archive_upload_to(obj, filename):
- now = timezone.now()
- return os.path.join(*map(str, ['minidump_archive', now.year, now.month,
- now.day, uuid.uuid4(), filename]))
+ return upload_to('minidump_archive', obj, filename)
class Crash(BaseModel):
diff --git a/omaha_server/feedback/models.py b/omaha_server/feedback/models.py
index 7c8713c..bb2ab2e 100644
--- a/omaha_server/feedback/models.py
+++ b/omaha_server/feedback/models.py
@@ -31,10 +31,18 @@ from jsonfield import JSONField
from omaha.models import BaseModel
from feedback.managers import FeedbackManager
+
def upload_to(directory, obj, filename):
now = timezone.now()
- return os.path.join(*map(str, [directory, now.year, now.month,
+ max_length = 100
+ path = os.path.join(*map(str, [directory, now.year, now.month,
now.day, uuid.uuid4(), filename]))
+ if len(path) > max_length:
+ name, ext = os.path.splitext(path)
+ ext_length = len(ext)
+ path = name[:max_length-ext_length] + ext
+ return path
+
def screenshot_upload_to(obj, filename):
return upload_to('screenshot', obj, filename)