merge_links() used wrong index
Because merge_links() use the index, we need to get the new_links() _before_ we manipulate the index with write_links_index(). This has the negative side effect that the "Adding X new links ..." will output twice (because we execute merge_links() twice. For that, we only output stuff when the only_new is not set.
This commit is contained in:
parent
69c007ce85
commit
b1b6be4f13
1 changed files with 3 additions and 3 deletions
|
@ -64,7 +64,7 @@ def merge_links(archive_path=OUTPUT_DIR, import_path=None, only_new=False):
|
||||||
all_links = validate_links(existing_links + all_links)
|
all_links = validate_links(existing_links + all_links)
|
||||||
|
|
||||||
num_new_links = len(all_links) - len(existing_links)
|
num_new_links = len(all_links) - len(existing_links)
|
||||||
if num_new_links:
|
if num_new_links and not only_new:
|
||||||
print('[{green}+{reset}] [{}] Adding {} new links from {} to {}/index.json'.format(
|
print('[{green}+{reset}] [{}] Adding {} new links from {} to {}/index.json'.format(
|
||||||
datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
num_new_links,
|
num_new_links,
|
||||||
|
@ -166,6 +166,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Step 1: Parse the links and dedupe them with existing archive
|
# Step 1: Parse the links and dedupe them with existing archive
|
||||||
links = merge_links(archive_path=out_dir, import_path=source, only_new=False)
|
links = merge_links(archive_path=out_dir, import_path=source, only_new=False)
|
||||||
|
new_links = merge_links(archive_path=out_dir, import_path=source, only_new=True)
|
||||||
|
|
||||||
# Step 2: Write new index
|
# Step 2: Write new index
|
||||||
write_links_index(out_dir=out_dir, links=links)
|
write_links_index(out_dir=out_dir, links=links)
|
||||||
|
@ -175,7 +176,6 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Step 4: Run the archive methods for each link
|
# Step 4: Run the archive methods for each link
|
||||||
if ONLY_NEW:
|
if ONLY_NEW:
|
||||||
new_links = merge_links(archive_path=out_dir, import_path=source, only_new=True)
|
|
||||||
update_archive(out_dir, new_links, source=source, resume=resume, append=True)
|
update_archive(out_dir, new_links, source=source, resume=resume, append=True)
|
||||||
else:
|
else:
|
||||||
update_archive(out_dir, links, source=source, resume=resume, append=True)
|
update_archive(out_dir, links, source=source, resume=resume, append=True)
|
||||||
|
|
Loading…
Add table
Reference in a new issue