summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wright <gienah@gentoo.org>2014-07-03 13:11:16 +0000
committerMark Wright <gienah@gentoo.org>2014-07-03 13:11:16 +0000
commit1ed0892bbb549e322ac8e41c36fcb6156c19c1e1 (patch)
treec787254217a5deb3d7ef3b024895325607382c1f /dev-vcs
parentKeyworded on alpha, bug #514448 (diff)
downloadhistorical-1ed0892bbb549e322ac8e41c36fcb6156c19c1e1.tar.gz
historical-1ed0892bbb549e322ac8e41c36fcb6156c19c1e1.tar.bz2
historical-1ed0892bbb549e322ac8e41c36fcb6156c19c1e1.zip
Update darcs-2.8.4-r6 from the gentoo-haskell overlay so it will build with recent haskell packages and ghc 7.8
Package-Manager: portage-2.2.10/cvs/Linux x86_64 Manifest-Sign-Key: 0x618E971F
Diffstat (limited to 'dev-vcs')
-rw-r--r--dev-vcs/darcs/ChangeLog11
-rw-r--r--dev-vcs/darcs/Manifest13
-rw-r--r--dev-vcs/darcs/darcs-2.8.4-r6.ebuild133
-rw-r--r--dev-vcs/darcs/files/darcs-2.8.4-fix-nonatomic-global.patch20
-rw-r--r--dev-vcs/darcs/files/darcs-2.8.4-ghc-7.8-part-2.patch14
-rw-r--r--dev-vcs/darcs/files/darcs-2.8.4-issue2364-part-2.patch52
-rw-r--r--dev-vcs/darcs/files/darcs-2.8.4-issue2364.patch70
7 files changed, 308 insertions, 5 deletions
diff --git a/dev-vcs/darcs/ChangeLog b/dev-vcs/darcs/ChangeLog
index 36d76c9ddd9d..c6f486a41c06 100644
--- a/dev-vcs/darcs/ChangeLog
+++ b/dev-vcs/darcs/ChangeLog
@@ -1,6 +1,15 @@
# ChangeLog for dev-vcs/darcs
# Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/dev-vcs/darcs/ChangeLog,v 1.54 2014/02/22 07:56:09 slyfox Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-vcs/darcs/ChangeLog,v 1.55 2014/07/03 13:11:09 gienah Exp $
+
+*darcs-2.8.4-r6 (03 Jul 2014)
+
+ 03 Jul 2014; Mark Wright <gienah@gentoo.org> +darcs-2.8.4-r6.ebuild,
+ +files/darcs-2.8.4-fix-nonatomic-global.patch,
+ +files/darcs-2.8.4-ghc-7.8-part-2.patch,
+ +files/darcs-2.8.4-issue2364-part-2.patch, +files/darcs-2.8.4-issue2364.patch:
+ Update darcs-2.8.4-r6 from the gentoo-haskell overlay so it will build with
+ recent haskell packages and ghc 7.8
22 Feb 2014; Sergei Trofimovich <slyfox@gentoo.org> -darcs-2.8.0.ebuild,
-files/darcs-2.8.0-mtl-2.1.patch:
diff --git a/dev-vcs/darcs/Manifest b/dev-vcs/darcs/Manifest
index ab65f8741ccd..35054b475ebb 100644
--- a/dev-vcs/darcs/Manifest
+++ b/dev-vcs/darcs/Manifest
@@ -1,16 +1,21 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
+AUX darcs-2.8.4-fix-nonatomic-global.patch 837 SHA256 f61a2e32a707d3fdcd9cad425e129018bce7d3ec291f0c84f14ff4e8056d5d6b SHA512 98c05960d2c5d74df7c934fc6d94f1f8367e04b07ad6189004d09ce190e9bb1799cf7cd43387dad8bc15230dbebd06ccc874e81460119c3d7b959c761e359825 WHIRLPOOL 37bd60dffbd3d2bdb94ee6eaf345d6d9cf61432e48754605124ddb48b900b443e0fb8989411689de1478c1a4ca9c191ac096b18222136911c530549d7e063e9c
AUX darcs-2.8.4-ghc-7.8-part-1.patch 5679 SHA256 454ca11d487379d3d7b19acae2c599bace01356c3f7c7a5cdace1018e82e6eda SHA512 9c6674e835227cae04074f82777a08e7b1cedc6b42deff7c271c53e2622b14217926a52ccba7651e3b7e0cfd40e0243e10529141ceae9044895d021af8ee1599 WHIRLPOOL f6063033e215dabd93e79a6b7417586ae75be89172c86c7c07ccabadc9b9593de6c83896c754314c281a5c2715ce56be4c2173b9f51582d01ad0273233ece1b0
+AUX darcs-2.8.4-ghc-7.8-part-2.patch 449 SHA256 1f8fcdc2c2c0b40d5062cbb45ec4a58f4e5777306ed4e126f7cb57a80a1ab410 SHA512 3dd469ea3f42f2b2c5388a9a47cdd4c901af2b663c8c1cb5ae75c595915e141652d3fe9f89b898483c06d3ee9b2d7df651b401e215b8aac0c1431b6e17639e41 WHIRLPOOL ed31ee69948625cd3b0c028d819eb71bb987582ae44749c4660cf0896c8d1584d2907fb246ec4019470a0d49becea0bcdee4cb8d7f9c90cd10c96dbf84a66cdb
+AUX darcs-2.8.4-issue2364-part-2.patch 1787 SHA256 f4468cdad4a344f48e3cefcf977d3423f4a5a98bce04326d6578d11b022cc19f SHA512 54594052d5492d98472da7aee611314bd08e3dfd3bfbe55b082cf3071048b4a066ddcdbbf445be6774255f406c8f67a6c9a76e536817354b89902ee30eeed02b WHIRLPOOL b07f0d58c06d44691e4a5ac907d35903fa80aeddb13d3c18cbd9368cbc270ae5baf77e90326a1b569b39db08505dd8d3cd14e0a8d31e325b32377c131f58fec9
+AUX darcs-2.8.4-issue2364.patch 2955 SHA256 82a427123f74a288bad08a23189be94b2137c5a264faa8e96e12ec527174b53c SHA512 01c70841c53bfdc8d047bd91609a30e37dee9def3c52930709a990ad4918461f01d5467ff9a0c0771def5151fdc5198c9a883c2f25ff2a16be756f60029f1e2e WHIRLPOOL f7f6cc4dfe2458a038cf1df5f8d72e1d0acd4245d297221fdf3d08c00576fbb0f7040e7498b0f21f0a43ef55298ada4e14eb46943566f901fd6450a73a67af5e
DIST darcs-2.8.4.tar.gz 1301464 SHA256 3fab4dbb2d5dd9f381d49f4730c12e1534b5c484b0dde9712614a7151f659f98 SHA512 c60531bacea43bdd5a18ae461dd390fe64682cac56fa4e6b5153a5da3c003b59d8fb24827bd42b4b30f0d2c61877d36b58eb98317644f9f8a200ab7c5961c48e WHIRLPOOL 128e8e58e219d427928eb8725d9566c1b6b3bb478b3cda69b30ded8798fa104eb8dec0fda8a32701f5d074babf9f11f1b3036388cd15a82118853a566c832430
EBUILD darcs-2.8.4-r3.ebuild 4518 SHA256 02f691062bdd148c0bc42bd9b805de612f05cc53354a73e063542814e2926498 SHA512 6adbf8b0217e1d7e2b0455896b194e256cbc019962037f592491d77bf338167277093ccc66ef359f9e7edc84c2629159406c0a91af93bdbc4f4a58bcfe24bb89 WHIRLPOOL 270679efd2794d8322c85f56dcc8c40021bd2eaba5d6fea89e792bc1be6786733f78c1069025cad6b034c57f4055261674e70b05fc95d348b46dbd6ece72e739
+EBUILD darcs-2.8.4-r6.ebuild 4770 SHA256 b16685a53448b862b4ea9650961b37b8c6d8fd5ab4e7bd3fb12df54b527ff3b9 SHA512 d86f33759b3bce182fab171d42e49c567289359ad51de206c1d195208b69cca3aa2987e0693068ddcd98497aa3686db9c69b867e644d301edb8fffb7e62bb46c WHIRLPOOL f2c2e8aef8e3b71cfe9ea92da34013d061950d16b7ac6dcbf0b0edfc928879d0f6eed686b6b54e2d70832396d7a8e94dc4cec779dbaec3cd65d741abd822c383
EBUILD darcs-2.8.4.ebuild 4007 SHA256 da954f2190488bf79281f4fb886e4905449b4558f60fb011702eb4c13a2f6166 SHA512 c4a5ffc93b719eb33cf43f869a4b2db67b3bc96a6296188900c15020fe536670f1eee4ff33605fb6a193ac0a0d533a6d47dd6bb79edf266065f50405634c31ba WHIRLPOOL ed40c3cc1e73a2bcc87d59a645e99f107387d104e553ccc515ab7c11aa5dc06473395ac6753ea20c0fc5bd2c667ed777b39a6939a20f6c730f6cb7223dda544b
-MISC ChangeLog 26654 SHA256 f82c98e1e795b50729ae167102ae73245157a8241e0c2c1e531ac152e99d31cd SHA512 5b5440bbee2b66999bfc068c6443ad0a8506da0d6f7f19eda3f66f8169c5f5541c016723aafd146e97f79924e2543bed60a2e59c80d3332dd912375a30f5e71f WHIRLPOOL 712c66d576bf9c93ee12834e5ce82069f3c677005b86c61674e71e28fac89c46ad1bf821c2b3bc34c2ccf635c362b187edfafc6110548f61d64b98a2c22a0dfc
+MISC ChangeLog 27046 SHA256 dca689981e9ece6432c31e658c17e2327d77f54b8cc515d0c49656bb872877a4 SHA512 a8b6d0d59b956c16a541c93c867d58b727a00a0638c9af215115960c71cb46f02332cb4cd34d4174d41edb615acd6f12562e739c336675aaa4b6322c05eace58 WHIRLPOOL f347f1030fa04368e11d1356992a2f9cab6c3c79f9fa0ed56777006dcefb0094db2265573c79e67d18a979afedb3566bb1a5789ac3f290136e2895e12f240ec8
MISC metadata.xml 223 SHA256 1d00c8be162a6cb87b3de440b3e63e10b39c12d56e8fbfe592e75aed872b2508 SHA512 24765bbf1cb187cd262aa7fb3824c1cec65e2bf3f2198099de688916d96401a26458265b15408f22b1fbd6d6a2842df814a57ceda80dfa00d130b24423b7544f WHIRLPOOL 8fd6700f6198db6540eb51edf11372faeb6eb8a542a692e515badf236f62444f2c180f7d08e0f98e9fdfa23de14631b31af50543469aaa27084d6b637e2644c7
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
-iEYEAREIAAYFAlMIWAwACgkQcaHudmEf86rGZwCdHT7BvyxYbdaFpV95FCd24acv
-QvMAnAjtWJtzW/Iob29IY6c7ZzSPEdTM
-=pGk8
+iF4EAREIAAYFAlO1VnIACgkQoBEVQmGOlx/nyQEAngMgdyHu/sLVhAejeg1HSx4K
+fBi3gy9rfMzo/1VPexcA/j43Qe0rxjo4pelT1qFlyuGvyjUlBxGCHIA4G5yIBze3
+=+npt
-----END PGP SIGNATURE-----
diff --git a/dev-vcs/darcs/darcs-2.8.4-r6.ebuild b/dev-vcs/darcs/darcs-2.8.4-r6.ebuild
new file mode 100644
index 000000000000..5c7da0e8e864
--- /dev/null
+++ b/dev-vcs/darcs/darcs-2.8.4-r6.ebuild
@@ -0,0 +1,133 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-vcs/darcs/darcs-2.8.4-r6.ebuild,v 1.1 2014/07/03 13:11:09 gienah Exp $
+
+EAPI=5
+
+# ebuild generated by hackport 0.3.9999
+
+CABAL_FEATURES="bin lib profile haddock hoogle hscolour"
+inherit eutils haskell-cabal bash-completion-r1
+
+DESCRIPTION="a distributed, interactive, smart revision control system"
+HOMEPAGE="http://darcs.net/"
+SRC_URI="mirror://hackage/packages/archive/${PN}/${PV}/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0/${PV}"
+KEYWORDS="~alpha ~amd64 ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd ~x86-freebsd ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~x86-solaris"
+IUSE="doc test"
+
+RDEPEND="=dev-haskell/extensible-exceptions-0.1*:=[profile?]
+ >=dev-haskell/hashed-storage-0.5.6:=[profile?]
+ <dev-haskell/hashed-storage-0.6:=[profile?]
+ >=dev-haskell/haskeline-0.6.3:=[profile?]
+ <dev-haskell/haskeline-0.8:=[profile?]
+ =dev-haskell/html-1.0*:=[profile?]
+ =dev-haskell/mmap-0.5*:=[profile?]
+ >=dev-haskell/mtl-1.0:=[profile?]
+ <dev-haskell/mtl-2.3:=[profile?]
+ >=dev-haskell/parsec-2.0:=[profile?]
+ <dev-haskell/parsec-3.2:=[profile?]
+ =dev-haskell/random-1.0*:=[profile?]
+ >=dev-haskell/regex-compat-0.95.1:=[profile?]
+ >=dev-haskell/tar-0.3:=[profile?]
+ <dev-haskell/tar-0.5:=[profile?]
+ >=dev-haskell/terminfo-0.3:=[profile?] <dev-haskell/terminfo-0.5:=[profile?]
+ >=dev-haskell/text-0.11.0.6:=[profile?]
+ >=dev-haskell/vector-0.7:=[profile?]
+ >=dev-haskell/zlib-0.5.1.0:=[profile?]
+ <dev-haskell/zlib-0.6.0.0:=[profile?]
+ >=dev-lang/ghc-6.10.4:=
+ net-misc/curl"
+DEPEND="${RDEPEND}
+ >=dev-haskell/cabal-1.8
+ doc? ( virtual/latex-base
+ || ( dev-tex/latex2html[png]
+ dev-tex/latex2html[gif]
+ )
+ )
+ test? ( >=dev-haskell/cmdlib-0.2.1[profile?]
+ <dev-haskell/cmdlib-0.4[profile?]
+ =dev-haskell/findbin-0.0*[profile?]
+ >=dev-haskell/quickcheck-2.3
+ >=dev-haskell/shellish-0.1.3[profile?]
+ <dev-haskell/shellish-0.2[profile?]
+ >=dev-haskell/test-framework-0.4.0[profile?]
+ >=dev-haskell/test-framework-hunit-0.2.2[profile?]
+ >=dev-haskell/test-framework-quickcheck2-0.2.8[profile?]
+ )
+ "
+
+src_prepare() {
+ rm "${S}/tests/add_permissions.sh" || die "Could not rm add_permissions.sh"
+ rm "${S}/tests/send-output-v1.sh" || die "Could not rm send-output-v1.sh"
+ rm "${S}/tests/send-output-v2.sh" || die "Could not rm send-output-v2.sh"
+ rm "${S}/tests/utf8.sh" || die "Could not rm utf8.sh"
+
+ epatch "${FILESDIR}"/${P}-ghc-7.8-part-1.patch
+ epatch "${FILESDIR}"/${P}-ghc-7.8-part-2.patch
+ epatch "${FILESDIR}"/${P}-fix-nonatomic-global.patch
+ epatch "${FILESDIR}"/${P}-issue2364.patch
+ epatch "${FILESDIR}"/${P}-issue2364-part-2.patch
+
+ cabal_chdeps \
+ 'text >= 0.11.0.6 && < 0.12.0.0' 'text >= 0.11.0.6' \
+ 'terminfo == 0.3.*' 'terminfo >= 0.3 && < 0.5' \
+ 'array >= 0.1 && < 0.5' 'array >= 0.1 && <0.6' \
+ 'process >= 1.0.0.0 && < 1.2.0.0' 'process >= 1.0.0.0 && < 1.3' \
+ 'unix >= 1.0 && < 2.7' 'unix >=1.0 && <2.8' \
+ 'base >= 4.5 && < 4.7' 'base >= 4.5 && < 4.8' \
+ 'ghc >= 6.10 && < 7.8' 'ghc >= 6.10' \
+ 'mtl >= 1.0 && < 2.2' 'mtl >= 1.0 && < 2.3'
+}
+
+src_configure() {
+ # checking whether ghc supports -threaded flag
+ # Beware: http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#options-linker
+ # contains: 'The ability to make a foreign call that does not block all other Haskell threads.'
+ # It might have interactivity impact.
+
+ threaded_flag=""
+ if $(ghc-getghc) --info | grep "Support SMP" | grep -q "YES"; then
+ threaded_flag="--flags=threaded"
+ einfo "$P will be built with threads support"
+ else
+ threaded_flag="--flags=-threaded"
+ einfo "$P will be built without threads support"
+ fi
+
+ # Use curl for net stuff to avoid strict version dep on HTTP and network
+ cabal_src_configure \
+ --flags=curl \
+ --flags=-http \
+ --flags=color \
+ --flags=terminfo \
+ --flags=mmap \
+ --flags=force-char8-encoding \
+ $threaded_flag \
+ $(cabal_flag test)
+}
+
+src_test() {
+ # run cabal test from haskell-cabal
+ haskell-cabal_src_test || die "cabal test failed"
+}
+
+src_install() {
+ cabal_src_install
+ newbashcomp "${S}/contrib/darcs_completion" "${PN}"
+
+ # fixup perms in such an an awkward way
+ mv "${ED}/usr/share/man/man1/darcs.1" "${S}/darcs.1" || die "darcs.1 not found"
+ doman "${S}/darcs.1" || die "failed to register darcs.1 as a manpage"
+}
+
+pkg_postinst() {
+ ghc-package_pkg_postinst
+
+ ewarn "NOTE: in order for the darcs send command to work properly,"
+ ewarn "you must properly configure your mail transport agent to relay"
+ ewarn "outgoing mail. For example, if you are using ssmtp, please edit"
+ ewarn "${EPREFIX}/etc/ssmtp/ssmtp.conf with appropriate values for your site."
+}
diff --git a/dev-vcs/darcs/files/darcs-2.8.4-fix-nonatomic-global.patch b/dev-vcs/darcs/files/darcs-2.8.4-fix-nonatomic-global.patch
new file mode 100644
index 000000000000..c3fce6fbc9e8
--- /dev/null
+++ b/dev-vcs/darcs/files/darcs-2.8.4-fix-nonatomic-global.patch
@@ -0,0 +1,20 @@
+There is a bug in speculateFileOrUrl.
+It puts downloaded file nonatomically.
+
+There is a window when copyFileOrUrl can (and does)
+copy partially downloaded file.
+
+Darcs-bug: http://bugs.darcs.net/issue2364
+diff --git a/src/Darcs/External.hs b/src/Darcs/External.hs
+index 2e0e791..d5a0b9f 100644
+--- a/src/Darcs/External.hs
++++ b/src/Darcs/External.hs
+@@ -184,7 +184,7 @@ copyFileOrUrl rd fou out _ | isSshUrl fou = copySSH rd (splitSshUrl fou)
+ copyFileOrUrl _ fou _ _ = fail $ "unknown transport protocol: " ++ fou
+
+ speculateFileOrUrl :: String -> FilePath -> IO ()
+-speculateFileOrUrl fou out | isHttpUrl fou = speculateRemote fou out
++speculateFileOrUrl fou out | isHttpUrl fou = speculateRemote fou out >> waitUrl fou
+ | otherwise = return ()
+
+ copyLocal :: String -> FilePath -> IO ()
diff --git a/dev-vcs/darcs/files/darcs-2.8.4-ghc-7.8-part-2.patch b/dev-vcs/darcs/files/darcs-2.8.4-ghc-7.8-part-2.patch
new file mode 100644
index 000000000000..33786477b3fa
--- /dev/null
+++ b/dev-vcs/darcs/files/darcs-2.8.4-ghc-7.8-part-2.patch
@@ -0,0 +1,14 @@
+diff --git a/src/Darcs/Test/Patch.hs b/src/Darcs/Test/Patch.hs
+index 0f7ed24..078fbc3 100644
+--- a/src/Darcs/Test/Patch.hs
++++ b/src/Darcs/Test/Patch.hs
+@@ -2,6 +2,9 @@
+ #if __GLASGOW_HASKELL__ >= 700
+ {-# LANGUAGE ImpredicativeTypes #-}
+ #endif
++#if __GLASGOW_HASKELL__ >= 708
++{-# LANGUAGE AllowAmbiguousTypes #-}
++#endif
+ -- Copyright (C) 2002-2005,2007 David Roundy
+ --
+ -- This program is free software; you can redistribute it and/or modify
diff --git a/dev-vcs/darcs/files/darcs-2.8.4-issue2364-part-2.patch b/dev-vcs/darcs/files/darcs-2.8.4-issue2364-part-2.patch
new file mode 100644
index 000000000000..6164a4a00074
--- /dev/null
+++ b/dev-vcs/darcs/files/darcs-2.8.4-issue2364-part-2.patch
@@ -0,0 +1,52 @@
+Tue May 13 22:07:19 FET 2014 Sergei Trofimovich <slyfox@community.haskell.org>
+ * resolve issue2364: don't break list of 'bad sources'
+
+ This time the bug manifested on a simple operation:
+ $ darcs record -a -m "something"
+
+ Attempt to write a patch resulted in something like:
+ Failed to record patch 'hello'
+
+ HINT: I could not reach the following repositories:
+ http://repetae.net/repos/jhc
+ /home/st/.darcs/cache
+ /home/st/.cache/darcs
+ /home/st/dev/darcs/jhc
+ If you're not using them, you should probably delete
+
+ The sequence should be the following:
+ 1. store patch to inventory/foo
+ 2. try to store to a writable cache (say, ~/.darcs/cache/patches)
+ 3. fail to write
+ 4. filter out bad caches
+ 5. try again
+ 6. copy from cache to patches/
+
+ Due to missing NOINLINE step 4. led to
+ all caches treated as writable, thus step 5
+ failed without a chance for patch to
+ go to 'patches/'.
+
+ As a side-effect building darcs with -O0 produced seemingly working darcs.
+ Reported-by: Ivan Miljenovic
+diff -rN -u old-darcs.net/src/Darcs/Util/Global.hs new-darcs.net/src/Darcs/Util/Global.hs
+--- old-darcs.net/src/Darcs/Global.hs 2014-05-13 22:23:29.897329750 +0300
++++ new-darcs.net/src/Darcs/Global.hs 2014-05-13 22:23:29.979329754 +0300
+@@ -135,7 +135,7 @@
+
+ _badSourcesList :: IORef [String]
+ _badSourcesList = unsafePerformIO $ newIORef []
+-{- NOINLINE _badSourcesList -}
++{-# NOINLINE _badSourcesList #-}
+
+
+ addBadSource :: String -> IO ()
+@@ -154,7 +154,7 @@
+
+ _reachableSourcesList :: IORef [String]
+ _reachableSourcesList = unsafePerformIO $ newIORef []
+-{- NOINLINE _reachableSourcesList -}
++{-# NOINLINE _reachableSourcesList #-}
+
+
+ addReachableSource :: String -> IO ()
diff --git a/dev-vcs/darcs/files/darcs-2.8.4-issue2364.patch b/dev-vcs/darcs/files/darcs-2.8.4-issue2364.patch
new file mode 100644
index 000000000000..97c4e0f1ad2b
--- /dev/null
+++ b/dev-vcs/darcs/files/darcs-2.8.4-issue2364.patch
@@ -0,0 +1,70 @@
+* resolve issue2364: fix file corruption on double fetch
+
+The bug is the result of attempt to fetch the same file
+(say F) by the same URL (U) multiple times concurrently.
+
+First time U gets fetched by speculative prefetch logic.
+Second time as an ordinary file (while first fetch is not finished).
+
+The function 'copyUrlWithPriority' sends download request
+to 'urlChan' both times (it's already not a nice situation,
+fixed by this patch).
+
+Later urlThread satisfies first request, notifies receiver,
+and starts downloading exactly the same U again.
+
+I don't know exact data corruption mechanics yet, but it has
+to do with non-random intermediate file names of downloaded
+files and 'truncate' call when temp file is opened for a new
+downlaod job.
+
+All temp names are completely non-random for a single darcs run:
+
+ urlThread :: Chan UrlRequest -> IO ()
+ urlThread ch = do
+ junk <- flip showHex "" `fmap` randomRIO rrange
+ evalStateT urlThread' (UrlState Map.empty emptyQ 0 junk)
+
+ createDownloadFileName :: FilePath -> UrlState -> FilePath
+ createDownloadFileName f st = f ++ "-new_" ++ randomJunk st
+
+My theory is next download manages to step on toes of previous job.
+
+I'll try to make file names truly random in other patch.
+That way such errors should manifest as read erros instead of data
+corruption.
+
+Thanks!
+diff --git a/src/URL.hs b/src/URL.hs
+index 4cb85ee..26de278 100644
+--- a/src/URL.hs
++++ b/src/URL.hs
+@@ -18,11 +18,12 @@ module URL ( copyUrl, copyUrlFirst, setDebugHTTP,
+ import Data.IORef ( newIORef, readIORef, writeIORef, IORef )
+ import Data.Map ( Map )
+ import qualified Data.Map as Map
++import Data.Tuple ( swap )
+ import System.Directory ( copyFile )
+ import System.IO.Unsafe ( unsafePerformIO )
+ import Control.Concurrent ( forkIO )
+ import Control.Concurrent.Chan ( isEmptyChan, newChan, readChan, writeChan, Chan )
+-import Control.Concurrent.MVar ( isEmptyMVar, modifyMVar_, newEmptyMVar, newMVar, putMVar, readMVar, withMVar, MVar )
++import Control.Concurrent.MVar ( isEmptyMVar, modifyMVar, modifyMVar_, newEmptyMVar, newMVar, putMVar, readMVar, withMVar, MVar )
+ import Control.Monad ( unless, when )
+ import Control.Monad.Trans ( liftIO )
+ import Control.Monad.State ( evalStateT, get, modify, put, StateT )
+@@ -196,10 +197,10 @@ copyUrlWithPriority p u f c = do
+ debugMessage ("URL.copyUrlWithPriority ("++u++"\n"++
+ " -> "++f++")")
+ v <- newEmptyMVar
+- let fn _ old_val = old_val
+- modifyMVar_ urlNotifications (return . (Map.insertWith fn u v))
+- let r = UrlRequest u f c p
+- writeChan urlChan r
++ old_mv <- modifyMVar urlNotifications (return . swap . Map.insertLookupWithKey (\_k _n old -> old) u v)
++ case old_mv of
++ Nothing -> writeChan urlChan $ UrlRequest u f c p -- ok, new URL
++ Just _ -> debugMessage $ "URL.copyUrlWithPriority already in progress, skip (" ++ u ++ "\n" ++ "-> " ++ f ++ ")"
+
+ waitNextUrl :: StateT UrlState IO ()
+ waitNextUrl = do