mirror of https://github.com/sbt/sbt.git
Merge pull request #120 from duboisf/ro_file_projectref
Readonly file ProjectRef
This commit is contained in:
commit
671053c62f
|
|
@ -46,10 +46,29 @@ object RetrieveUnit
|
|||
case "http" | "https" => Some { () => downloadAndExtract(base, tmp); tmp }
|
||||
case "file" =>
|
||||
val f = new File(base)
|
||||
if(f.isDirectory) Some(() => f) else None
|
||||
if(f.isDirectory)
|
||||
{
|
||||
val finalDir = if (!f.canWrite) retrieveRODir(f, tmp) else f
|
||||
Some(() => finalDir)
|
||||
}
|
||||
else None
|
||||
case _ => None
|
||||
}
|
||||
}
|
||||
def retrieveRODir(base: File, tempDir: File): File =
|
||||
{
|
||||
if (!tempDir.exists)
|
||||
{
|
||||
try {
|
||||
IO.copyDirectory(base, tempDir)
|
||||
} catch {
|
||||
case e =>
|
||||
IO.delete(tempDir)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
tempDir
|
||||
}
|
||||
def downloadAndExtract(base: URI, tempDir: File): Unit = if(!tempDir.exists) IO.unzipURL(base.toURL, tempDir)
|
||||
def temporary(tempDir: File, uri: URI): File = new File(tempDir, Hash.halve(hash(uri)))
|
||||
def hash(uri: URI): String = Hash.toHex(Hash(uri.toASCIIString))
|
||||
|
|
|
|||
Loading…
Reference in New Issue