summaryrefslogtreecommitdiff
path: root/ishtar_common/management/commands/media_find_missing_files.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/management/commands/media_find_missing_files.py')
-rw-r--r--ishtar_common/management/commands/media_find_missing_files.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/ishtar_common/management/commands/media_find_missing_files.py b/ishtar_common/management/commands/media_find_missing_files.py
index 226699842..73f4e0ccf 100644
--- a/ishtar_common/management/commands/media_find_missing_files.py
+++ b/ishtar_common/management/commands/media_find_missing_files.py
@@ -38,7 +38,7 @@ class Command(BaseCommand):
)
parser.add_argument(
'--limit', nargs='?', dest='limit', default=None,
- help="Field to limit to separated with \",\"."
+ help="Field to limit to. Separate field names with \",\"."
)
parser.add_argument(
'--try-fix', dest='try-fix', action='store_true',
@@ -48,16 +48,24 @@ class Command(BaseCommand):
'--find-fix', dest='find-fix', action='store_true',
default=False,
help='Try to find file with similar names and print them.')
+ parser.add_argument(
+ '--hard', dest='hard', action='store_true',
+ default=False,
+ help='Search on the whole media dir.')
def handle(self, *args, **options):
exclude = options['exclude'].split(',') if options['exclude'] else []
limit = options['limit'].split(',') if options['limit'] else []
try_fix = options['try-fix']
find_fix = options['find-fix']
+ hard = options['hard']
if try_fix and find_fix:
self.stdout.write("try-fix and find-fix options are not "
"compatible.\n")
return
+ if hard and not (try_fix or find_fix):
+ self.stdout.write("hard option has no effect if try-fix or "
+ "find-fix are not set.\n")
missing = []
for media in get_used_media(exclude=exclude, limit=limit):
@@ -70,7 +78,8 @@ class Command(BaseCommand):
else:
self.stdout.write("* fixes files:\n")
for item in missing[:]:
- source_file = try_fix_file(item, make_copy=try_fix)
+ source_file = try_fix_file(item, make_copy=try_fix,
+ hard=hard)
if source_file:
missing.pop(missing.index(item))
sys.stdout.write(
@@ -82,6 +91,6 @@ class Command(BaseCommand):
self.stdout.write("* missing file with no similar file "
"found:\n")
for item in missing:
- sys.stdout.write(item.encode('utf-8') + "\n")
+ sys.stdout.write(item + "\n")
else:
self.stdout.write("No missing files.\n")