harden clean and IO.move

This commit is contained in:
Mark Harrah 2011-04-12 23:10:36 -04:00
parent fe75bade98
commit 1c400db4d9
2 changed files with 2 additions and 1 deletions

View File

@ -287,7 +287,7 @@ object Defaults
def doClean(clean: Seq[File], preserve: Seq[File]): Unit =
IO.withTemporaryDirectory { temp =>
val mappings = preserve.zipWithIndex map { case (f, i) => (f, new File(temp, i.toHexString)) }
val mappings = preserve.filter(_.exists).zipWithIndex map { case (f, i) => (f, new File(temp, i.toHexString)) }
IO.move(mappings)
IO.delete(clean)
IO.move(mappings.map(_.swap))

View File

@ -574,6 +574,7 @@ object IO
{
if(b.exists)
delete(b)
createDirectory(b.getParentFile)
if(!a.renameTo(b))
{
copyFile(a, b, true)