From 1c400db4d99f3e60f483a0999b7244e01a5ef798 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Tue, 12 Apr 2011 23:10:36 -0400 Subject: [PATCH] harden clean and IO.move --- main/Defaults.scala | 2 +- util/io/IO.scala | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/main/Defaults.scala b/main/Defaults.scala index a13d5ab0a..45dc01f4a 100644 --- a/main/Defaults.scala +++ b/main/Defaults.scala @@ -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)) diff --git a/util/io/IO.scala b/util/io/IO.scala index f0eb79757..724ecefdf 100644 --- a/util/io/IO.scala +++ b/util/io/IO.scala @@ -574,6 +574,7 @@ object IO { if(b.exists) delete(b) + createDirectory(b.getParentFile) if(!a.renameTo(b)) { copyFile(a, b, true)