mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-23 13:36:35 +00:00
parent
ff91cbf6ba
commit
533c1631b7
@ -16,7 +16,7 @@ class Command(BaseCommand):
|
||||
log.info('Building directory to Source map...')
|
||||
dirmap = {}
|
||||
for s in Source.objects.all():
|
||||
dirmap[s.directory_path] = s
|
||||
dirmap[str(s.directory_path)] = s
|
||||
log.info(f'Scanning sources...')
|
||||
file_extensions = list(FileExtension.values) + self.extra_extensions
|
||||
for sourceroot, source in dirmap.items():
|
||||
@ -38,7 +38,8 @@ class Command(BaseCommand):
|
||||
ext = ext.strip().lower()
|
||||
if ext not in file_extensions:
|
||||
continue
|
||||
on_disk.append(str(rootpath / filename))
|
||||
filepath = Path(rootpath / filename).resolve(strict=True)
|
||||
on_disk.append(str(filepath))
|
||||
filemap = {}
|
||||
for item in media:
|
||||
for filepath in on_disk:
|
||||
@ -50,7 +51,8 @@ class Command(BaseCommand):
|
||||
for filepath, item in filemap.items():
|
||||
log.info(f'Matched on-disk file: {filepath} '
|
||||
f'to media item: {item.source} / {item}')
|
||||
item.media_file.name = filepath
|
||||
item.media_file.name = str(Path(filepath).relative_to(item.media_file.storage.location))
|
||||
item.downloaded = True
|
||||
item.downloaded_filesize = Path(filepath).stat().st_size
|
||||
item.save()
|
||||
log.info('Done')
|
||||
|
Loading…
Reference in New Issue
Block a user