Merge pull request #7 from apoclyps/docker-support

[ISSUE-3] Adding docker support
This commit is contained in:
2019-07-25 22:06:52 +01:00
committed by Apoclyps
54 changed files with 2106 additions and 1476 deletions

View File

@@ -7,11 +7,11 @@ from comic.models import Setting, Directory, ComicBook
class Command(BaseCommand):
help = 'Scan directories to Update Comic DB'
help = "Scan directories to Update Comic DB"
def __init__(self):
super().__init__()
self.base_dir = Setting.objects.get(name='BASE_DIR').value
self.base_dir = Setting.objects.get(name="BASE_DIR").value
def handle(self, *args, **options):
self.scan_directory()
@@ -36,25 +36,21 @@ class Command(BaseCommand):
for file in os.listdir(comic_dir):
if isdir(os.path.join(comic_dir, file)):
if directory:
next_directory, created = Directory.objects.get_or_create(name=file,
parent=directory)
next_directory, created = Directory.objects.get_or_create(name=file, parent=directory)
else:
next_directory, created = Directory.objects.get_or_create(name=file,
parent__isnull=True)
next_directory, created = Directory.objects.get_or_create(name=file, parent__isnull=True)
if created:
next_directory.save()
self.scan_directory(next_directory)
else:
try:
if directory:
book = ComicBook.objects.get(file_name=file,
directory=directory)
book = ComicBook.objects.get(file_name=file, directory=directory)
if book.version == 0:
book.version = 1
book.save()
else:
book = ComicBook.objects.get(file_name=file,
directory__isnull=True)
book = ComicBook.objects.get(file_name=file, directory__isnull=True)
if book.version == 0:
if directory:
book.directory = directory