diff options
author | Rob Austein <sra@hactrn.net> | 2012-03-01 01:30:04 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2012-03-01 01:30:04 +0000 |
commit | 7609726054549996b49c13102080b6fae110751e (patch) | |
tree | d453bf1c320a815d592b2bc51167ceb5d3f9e8d5 /rcynic | |
parent | ece2557835748dddb880b0b7574f47af9e2d1f3d (diff) |
Ignore atomic installation issue for now. Maybe ask author of
paramiko about it some day.
svn path=/trunk/; revision=4380
Diffstat (limited to 'rcynic')
-rw-r--r-- | rcynic/rpki-torrent.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/rcynic/rpki-torrent.py b/rcynic/rpki-torrent.py index e533a264..0e52622f 100644 --- a/rcynic/rpki-torrent.py +++ b/rcynic/rpki-torrent.py @@ -102,8 +102,6 @@ def main(): def generator_main(): import paramiko - paramiko.util.log_to_file("sftp_debug.log") - z = ZipFile(url = cfg.generate_url, dir = cfg.zip_dir) client = TransmissionClient() @@ -126,11 +124,12 @@ def generator_main(): except OSError, e: if e.errno != errno.ENOENT: raise - subprocess.check_call((cfg.mktorrent_prog, - "-a", cfg.tracker_url, - "-c", "RPKI unauthenticated data snapshot generated by rpki-torrent", - "-o", torrent_file, - torrent_dir)) + ignore_output_for_now = subprocess.check_output( + (cfg.mktorrent_prog, + "-a", cfg.tracker_url, + "-c", "RPKI unauthenticated data snapshot generated by rpki-torrent", + "-o", torrent_file, + torrent_dir)) syslog.syslog("Generating manifest") manifest = create_manifest(download_dir, z.torrent_name) @@ -176,12 +175,24 @@ def generator_main(): z.close() f.close() - # Yearg! It breaks here, because paramiko doesn't use the - # posix-rename@openssh.com extension and the default sftp behavior - # is to fail if the file already exists! So much for atomic - # installation via this hack. I wonder how hard it would be to add - # support for the posix-rename extension? + # Feh, atomic rename isn't part of the non-standard, well, it sort + # of is part of the last version of the non-standard before the IETF + # SECSH WG abandoned the specification, but paramiko doesn't support + # it, and my lame attempts to patch it in didn't work, perhaps + # because OpenSSH doesn't really support it either, they have their + # own extension instead. + # + # But we're here to get a job done, so for now just live with a + # brief race condition. Feh. + + zip_oldname = zip_filename + ".old" + + try: + sftp.remove(zip_oldname) + except IOError: + pass + sftp.rename(zip_filename, zip_oldname) sftp.rename(zip_tempname, zip_filename) syslog.syslog("Closing upload connection") |