Kaynağa Gözat

Fix a leaking file descriptor.

Julian Berman 6 yıl önce
ebeveyn
işleme
eb641b3e35
1 değiştirilmiş dosya ile 2 ekleme ve 1 silme
  1. 2 1
      archivebox/index.py

+ 2 - 1
archivebox/index.py

@@ -186,7 +186,8 @@ def patch_links_index(link, out_dir=OUTPUT_DIR):
 
     # Patch HTML index
     html_path = os.path.join(out_dir, 'index.html')
-    html = open(html_path, 'r').read().split('\n')
+    with open(html_path, 'r') as html_file:
+        html = [line[:-1] for line in html_file]
     for idx, line in enumerate(html):
         if title and ('<span data-title-for="{}"'.format(link['url']) in line):
             html[idx] = '<span>{}</span>'.format(title)