mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
add FileUtil.withTmpDir
This commit is contained in:
@@ -60,4 +60,14 @@ object FileUtil {
|
|||||||
case _ => ""
|
case _ => ""
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
def withTmpDir[A](dir: File)(action: File => A): A = {
|
||||||
|
if(dir.exists()){
|
||||||
|
FileUtils.deleteDirectory(dir)
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
action(dir)
|
||||||
|
}finally{
|
||||||
|
FileUtils.deleteDirectory(dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user