diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-08-31 11:55:49 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-08-31 11:55:49 +0200 |
commit | fc9a0fdeaef6920c3f7f0a6c1dd5cca40811f8d1 (patch) | |
tree | 1e38ca9770d04c9465a0c5cd8077ef9da6226863 /ishtar_common/management/commands/media_find_missing_files.py | |
parent | 89ce0dd5677d1673af9d6b2ee9e22999e9012117 (diff) | |
download | Ishtar-fc9a0fdeaef6920c3f7f0a6c1dd5cca40811f8d1.tar.bz2 Ishtar-fc9a0fdeaef6920c3f7f0a6c1dd5cca40811f8d1.zip |
"hard" option for media_find_missing_files command
Diffstat (limited to 'ishtar_common/management/commands/media_find_missing_files.py')
-rw-r--r-- | ishtar_common/management/commands/media_find_missing_files.py | 15 |
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") |