Mercurial > kallithea
changeset 5172:5260517c2802 stable
archive: fix archive failing first time on Windows - close file descriptor early
File descriptors is not used correctly - this is just a minimal stop gap.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 09 Jun 2015 22:12:21 +0200 |
parents | 1e079752b756 |
children | a73f98871e2b |
files | kallithea/controllers/files.py |
diffstat | 1 files changed, 2 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/files.py Sat May 16 16:37:17 2015 +0200 +++ b/kallithea/controllers/files.py Tue Jun 09 22:12:21 2015 +0200 @@ -556,7 +556,7 @@ cached_archive_path = os.path.join(CONFIG['archive_cache_dir'], archive_name) if os.path.isfile(cached_archive_path): log.debug('Found cached archive in %s' % cached_archive_path) - fd, archive = None, cached_archive_path + archive = cached_archive_path use_cached_archive = True else: log.debug('Archive %s is not yet cached' % (archive_name)) @@ -564,6 +564,7 @@ if not use_cached_archive: # generate new archive fd, archive = tempfile.mkstemp() + os.close(fd) temp_stream = open(archive, 'wb') log.debug('Creating new temp archive in %s' % archive) cs.fill_archive(stream=temp_stream, kind=fileformat, subrepos=subrepos) @@ -580,8 +581,6 @@ data = stream.read(16 * 1024) if not data: stream.close() - if fd: # fd means we used temporary file - os.close(fd) if not archive_cache_enabled: log.debug('Destroying temp archive %s' % archive) os.remove(archive)