Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 469888 | Differences between
and this patch

Collapse All | Expand All

(-)/tmp/bintree.py (-4 / +47 lines)
Lines 939-948 Link Here
939
							if not fcmd:
939
							if not fcmd:
940
								raise EnvironmentError("FETCHCOMMAND is unset")
940
								raise EnvironmentError("FETCHCOMMAND is unset")
941
941
942
						fd, tmp_filename = tempfile.mkstemp()
942
						# old method completely breaks timestamp caching
943
						tmp_dirname, tmp_basename = os.path.split(tmp_filename)
943
						# make a secure archive copy of our file (preserves timestamps)
944
						os.close(fd)
944
						# cd to tempdir so wget analyses the unqualified basename
945
						# fetch file
946
						# cd back
947
						
948
						tmp_dirname = tempfile.mkdtemp()
949
						fetch_cwd = os.getcwd()
950
						os.chdir(tmp_dirname)
951
						tmp_basename = os.path.basename(pkgindex_file)
945
952
953
						# no race condition since the target is atomically unlinked if exists
954
						fd_tmpfile,tmp_filename = tempfile.mkstemp(dir=tmp_dirname)
955
						os.rename(tmp_filename, tmp_basename)
956
						tmp_stat_original = None
957
958
						if os.path.exists(pkgindex_file):
959
							f_tmpfile = os.fdopen(fd_tmpfile, 'wb')
960
						
961
							# copy original file
962
							f_pkgindex_file = open(pkgindex_file, 'rb')
963
							f_tmpfile.write(f_pkgindex_file.read())
964
							f_tmpfile.close()
965
							f_pkgindex_file.close()
966
967
							# preserve timestamps
968
							os.utime(tmp_basename, (int(local_timestamp), int(local_timestamp)))
969
							tmp_stat_original = os.stat(tmp_basename)
970
						
971
						else:
972
							_f = os.path.exists('Packages')
973
							os.close(fd_tmpfile)
974
975
						fcmd = fcmd.replace('-O "${DISTDIR}/${FILE}"', '-N')
976
						
946
						fcmd_vars = {
977
						fcmd_vars = {
947
							"DISTDIR": tmp_dirname,
978
							"DISTDIR": tmp_dirname,
948
							"FILE": tmp_basename,
979
							"FILE": tmp_basename,
Lines 957-965 Link Here
957
988
958
						success = portage.getbinpkg.file_get(
989
						success = portage.getbinpkg.file_get(
959
							fcmd=fcmd, fcmd_vars=fcmd_vars)
990
							fcmd=fcmd, fcmd_vars=fcmd_vars)
991
992
						if tmp_stat_original and tmp_stat_original.st_ctime == os.stat(os.path.join(tmp_dirname, tmp_basename)).st_ctime:
993
							# set to the tmpdir so both are deleted
994
							tmp_filename = tmp_dirname
995
							os.chdir(fetch_cwd)
996
							raise UseCachedCopyOfRemoteIndex()
997
						
960
						if not success:
998
						if not success:
999
							os.chdir(fetch_cwd)
961
							raise EnvironmentError("%s failed" % (setting,))
1000
							raise EnvironmentError("%s failed" % (setting,))
962
						f = open(tmp_filename, 'rb')
1001
1002
						f = open(tmp_basename, 'rb')
1003
						# set to the tmpdir so both are deleted
1004
						tmp_filename = tmp_dirname
1005
						os.chdir(fetch_cwd)
963
1006
964
				f_dec = codecs.iterdecode(f,
1007
				f_dec = codecs.iterdecode(f,
965
					_encodings['repo.content'], errors='replace')
1008
					_encodings['repo.content'], errors='replace')

Return to bug 469888