diff options
Diffstat (limited to 'ishtar_common/utils.py')
| -rw-r--r-- | ishtar_common/utils.py | 16 | 
1 files changed, 15 insertions, 1 deletions
| diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index a3bc23e21..b4542688b 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -1499,6 +1499,20 @@ MEDIA_RE = [  ] +def get_broken_links(path): +    for root, dirs, files in os.walk(path): +        for filename in files: +            path = os.path.join(root, filename) +            if os.path.islink(path): +                target_path = os.readlink(path) +                # resolve relative symlinks +                if not os.path.isabs(target_path): +                    target_path = os.path.join(os.path.dirname(path), +                                               target_path) +                if not os.path.exists(target_path): +                    yield path + +  def simplify_name(full_path_name, check_existing=False, min_len=15):      """      Simplify a file name by removing auto save suffixes @@ -1766,7 +1780,7 @@ def try_fix_file(filename, make_copy=True, hard=False):      for path, __, files in os.walk(settings.MEDIA_ROOT):          for f in files:              result = _try_copy(path, f, filename, simplified_ref_name, -                               make_copy, min_len=15)  # 15 - less agressive +                               make_copy, min_len=10)              if result:                  return result | 
