forked from shaba/openuds
* Added owner to dbfile, so we can remove later them selectively
* Fixed samples
This commit is contained in:
parent
6766fe41fe
commit
50e368ee7a
@ -211,7 +211,7 @@ if DEBUG:
|
||||
# This is so because we need to share the files between servers
|
||||
# Another options is put /var/server/static on a shared nfs forder for all servers
|
||||
#
|
||||
# COMPRESS_STORAGE = 'uds.core.util.FileStorage.FileStorage'
|
||||
# COMPRESS_STORAGE = 'uds.core.util.FileStorage.CompressorFileStorage'
|
||||
|
||||
# See http://docs.djangoproject.com/en/dev/topics/logging for
|
||||
# more details on how to customize your logging configuration.
|
||||
|
@ -63,6 +63,11 @@ class FileStorage(Storage):
|
||||
cache = None
|
||||
|
||||
self.cache = cache
|
||||
if 'owner' in kwargs:
|
||||
self.owner = kwargs.get('owner')
|
||||
del kwargs['owner']
|
||||
else:
|
||||
self.owner = 'fstor'
|
||||
|
||||
self.cache._cache.flush_all() # On start, ensures that cache is empty to avoid surprises
|
||||
|
||||
@ -126,7 +131,7 @@ class FileStorage(Storage):
|
||||
try:
|
||||
f = self._dbFileForReadWrite(name)
|
||||
except DBFile.DoesNotExist:
|
||||
f = DBFile.objects.create(name=name)
|
||||
f = DBFile.objects.create(owner=self.owner, name=name)
|
||||
|
||||
f.data = content.read()
|
||||
f.save()
|
||||
@ -164,3 +169,8 @@ class FileStorage(Storage):
|
||||
def url(self, name):
|
||||
uuid = self._dbFileForReadWrite(name).uuid
|
||||
return urlparse.urljoin(self._base_url, uuid)
|
||||
|
||||
class CompressorFileStorage(FileStorage):
|
||||
def __init__(self, *args, **kwargs):
|
||||
FileStorage.__init__(self, *args, **dict(kwargs, owner='compressor'))
|
||||
|
||||
|
20
server/src/uds/migrations/0022_dbfile_owner.py
Normal file
20
server/src/uds/migrations/0022_dbfile_owner.py
Normal file
@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.5 on 2016-07-10 20:31
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('uds', '0021_auto_20160405_0429'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='dbfile',
|
||||
name='owner',
|
||||
field=models.CharField(default='', max_length=32),
|
||||
),
|
||||
]
|
@ -48,6 +48,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DBFile(UUIDModel):
|
||||
owner = models.CharField(max_length=32, default='') # Not indexed, used for cleanups only
|
||||
name = models.CharField(max_length=255, primary_key=True)
|
||||
content = models.TextField(blank=True)
|
||||
size = models.IntegerField(default=0)
|
||||
|
Loading…
Reference in New Issue
Block a user