fix bug in makeUnique
Returned the possibly non-unique file
This commit is contained in:
parent
8c55970413
commit
ac08924ec3
1 changed files with 3 additions and 3 deletions
|
@ -121,7 +121,7 @@ defaultTemplate = "${feedtitle}/${itemtitle}${extension}"
|
||||||
- has the same title. A number is added to disambiguate.
|
- has the same title. A number is added to disambiguate.
|
||||||
-}
|
-}
|
||||||
feedFile :: Utility.Format.Format -> ToDownload -> IO FilePath
|
feedFile :: Utility.Format.Format -> ToDownload -> IO FilePath
|
||||||
feedFile tmpl i = makeUnique 0 $
|
feedFile tmpl i = makeUnique 1 $
|
||||||
Utility.Format.format tmpl $ M.fromList
|
Utility.Format.format tmpl $ M.fromList
|
||||||
[ field "feedtitle" $ getFeedTitle $ feed i
|
[ field "feedtitle" $ getFeedTitle $ feed i
|
||||||
, fieldMaybe "itemtitle" $ getItemTitle $ item i
|
, fieldMaybe "itemtitle" $ getItemTitle $ item i
|
||||||
|
@ -148,10 +148,10 @@ makeUnique :: Integer -> FilePath -> IO FilePath
|
||||||
makeUnique n file =
|
makeUnique n file =
|
||||||
ifM (isJust <$> catchMaybeIO (getSymbolicLinkStatus f))
|
ifM (isJust <$> catchMaybeIO (getSymbolicLinkStatus f))
|
||||||
( makeUnique (n + 1) file
|
( makeUnique (n + 1) file
|
||||||
, return file
|
, return f
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
f = if n == 0
|
f = if n < 2
|
||||||
then file
|
then file
|
||||||
else
|
else
|
||||||
let (d, base) = splitFileName file
|
let (d, base) = splitFileName file
|
||||||
|
|
Loading…
Add table
Reference in a new issue