orphan files, fix vm build

This commit is contained in:
j 2011-12-16 19:43:37 +05:30
commit 00145a603b
2 changed files with 21 additions and 1 deletions

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from django.core.management.base import BaseCommand
from django.conf import settings
import os
from glob import glob
from ... import models
class Command(BaseCommand):
"""
"""
help = 'list files no longer without db entry'
args = ''
def handle(self, **options):
for f in glob(os.path.join(settings.MEDIA_ROOT, 'files', '*', '*', '*', '*')):
oshash = f[-19:].replace('/', '')
if models.File.objects.filter(oshash=oshash).count() == 0:
print f