Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/subscriptions/bin/updateSubscriptionDownloads.py

Issue 28037010: Improved generation of filter subscription files (Closed)
Left Patch Set: Fixed review comments Created Nov. 8, 2013, 3:05 p.m.
Right Patch Set: Different approach to atomic updates Created Nov. 11, 2013, 2:52 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | sitescripts/subscriptions/combineSubscriptions.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 if __name__ == "__main__": 44 if __name__ == "__main__":
45 setupStderr() 45 setupStderr()
46 46
47 source_repos = {} 47 source_repos = {}
48 for option, value in get_config().items("subscriptionDownloads"): 48 for option, value in get_config().items("subscriptionDownloads"):
49 if option.endswith("_repository"): 49 if option.endswith("_repository"):
50 source_repos[re.sub(r"_repository$", "", option)] = MercurialSource(value) 50 source_repos[re.sub(r"_repository$", "", option)] = MercurialSource(value)
51 51
52 basedir = get_config().get("subscriptionDownloads", "outdir") 52 basedir = get_config().get("subscriptionDownloads", "outdir")
53 destination = tempfile.mkdtemp(prefix="data.", dir=basedir) 53 destination = os.path.join(basedir, "data")
54 try: 54 try:
55 combine_subscriptions(source_repos, destination) 55 combine_subscriptions(source_repos, destination, tempdir=basedir)
56 except:
57 shutil.rmtree(destination, ignore_errors=True)
58 raise
59 finally: 56 finally:
60 for source in source_repos.itervalues(): 57 for source in source_repos.itervalues():
61 source.close() 58 source.close()
62
63 symbolic_link = os.path.join(basedir, "data")
64 symbolic_link_tmp = os.path.join(basedir, "data~")
65 orig_data = None
66 if os.path.islink(symbolic_link):
67 orig_data = os.path.join(basedir, os.readlink(symbolic_link))
68
69 os.symlink(os.path.relpath(destination, basedir), symbolic_link_tmp)
70 os.rename(symbolic_link_tmp, symbolic_link)
71
72 if orig_data:
73 shutil.rmtree(orig_data)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld