Skip to content

Commit 1850b0f

Browse files
committed
add celery task to cleanup old files
1 parent c080838 commit 1850b0f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ HOME=/home/django/your-app
159159
0 1 * * * root python manage.py cleanup_http_uploads
160160
```
161161

162+
### celery task
163+
164+
Alternatively, if you use [Celery](http://www.celeryproject.org/), you can also use the
165+
``xmpp_http_upload.cleanup_http_uploads`` task to cleanup your files.
166+
162167
## Development
163168

164169
If you want to use this app to develop e.g. a plugin for an XMPP server, you can simply do the

xmpp_http_upload/tasks.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of django-xmpp-http-upload
4+
# (https://github.com/mathiasertl/django-xmpp-http-upload).
5+
#
6+
# django-xmpp-http-upload is free software: you can redistribute it and/or modify it under the
7+
# terms of the GNU General Public License as published by the Free Software Foundation, either
8+
# version 3 of the License, or (at your option) any later version.
9+
#
10+
# django-xmpp-http-upload is distributed in the hope that it will be useful, but WITHOUT ANY
11+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12+
# PURPOSE. See the GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License along with
15+
# django-xmpp-http-upload. If not, see <http://www.gnu.org/licenses/>.
16+
17+
from celery import shared_task
18+
19+
from .models import Upload
20+
21+
22+
@shared_task
23+
def cleanup_http_uploads(slots=True, files=True, timeout=None):
24+
Upload.objects.cleanup(slots=slots, files=files, timeout=timeout)

0 commit comments

Comments
 (0)